1.

<html>

<head>

<title>Form Filling</title>

</head>

<body>

<h3 align="center">Creating Form And Count the Elements</h3>

<form id="newform" align="center"

<label id="name">Name:</label>

<input type="text"></input>

<br><br>

<label id="email">Email:</label>

<input type="text"></input>

<br><br>

<label for="gender">Gender:</label>

<input type="radio" id="male" name="gender" value="male">Male</input> <input type="radio" id="female" name="gender" value="female">Female</input>

<br><br>

<label for="class">Class:</label>

<input type="checkbox">I CS</input>

<input type="checkbox">II CS</input>

<input type="checkbox">III CS</input> <br><br>

<button onclick="fun();">Count</button>

<script>

function fun(){

var form = document.getElementById("newform");

var count = form.elements.length;

alert("Number of Elements: " + count);

}

</script>

</form>

</body>

</html>

Comments