For loop with alert dialog : For « Language Basics « JavaScript DHTML






For loop with alert dialog

  
<html>
<head>
<script language="JavaScript">
<!--
function seeElem(f)  {
  var elementList = "";
  for (var num=0; num < f.elements.length; num++) {
      elementList += num + ". " + f.elements[num] + "\n";
  }
  alert(elementList);
}
//-->
</script>
</head>
<body>
<form>
<table>
<tr>
 <td>Name:</td>
 <td><input name="persname" 
            type="text">
</tr>
<tr>
  <td>E-mail:</td>
  <td><input name="email" type="text"></td>
</tr>
</table>
<input type="button" value="See elements" onClick="seeElem(this.form)">
</form>
</body>
</html>


           
         
    
  








Related examples in the same category

1.For loop for lines
2.Check the loop counter
3. Drawing a Christmas Tree Using Nested For Loops
4.For loop
5.Using a for..in Loop in JavaScript
6.A Demonstration of a Nested Loop
7.A for Loop Used to Count from 0 to 99
8.Using the label Statement
9.Using the continue and break Statements
10.Use of the for Statement
11.The break Statement
12.The continue Statement
13.Labeled Statements
14.Plain for loop
15.Declare for loop counter
16.Control the loop step
17.Use for loop to fill an array
18.Use for in loop to go through an array