0% found this document useful (0 votes)
8 views2 pages

Ex1 1

Uploaded by

asaithambiasdf71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Ex1 1

Uploaded by

asaithambiasdf71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Create a form having number of elements (Textboxes, Radio buttons,

Checkboxes,
and so on). Write JavaScript code to count the number of elements in a
form.
< html>
<head>
<title> Count form elements </title>
<script type="text/javascript">
function countFormElements()
{
alert("the number of elements are :"+document.myForm.length);

}
</script>
</head>
<body bgcolor=cyan>
<h1 align=center>Counting Form Elements </h1>
<hr>
<form name="myForm" align=left>
1. Name : &nbsp&nbsp&nbsp&nbsp<input type=text/> <br><br>
2. Password: <input type="password"/><br><br>
3. Address:&nbsp&nbsp<textarea id="emailbody" cols=50 rows=10></textarea>
<br><br>
4. Sex:<input type=radio name=gender/>Male
<input type=radio name=gender/>Female<br><br>
5. Newsletter <input type=checkbox checked="checked"/><br><br>
<input type=button value="Send Message" onclick="countFormElements()" />
</form>
</body>
</html>

You might also like