Get form element infomation : JavaScript DHTML examples (example source code) » Form Control » Form Info

JavaScript DHTML
C++
Java Products
Java Articles
JavaScript DHTML Home  »   Form Control   » [  Form Info  ]   
 



Get form element infomation

Please note that some example is only working under IE or Firefox.

/*
Javascript Essentials
by Jason J. Manger

Publisher: Mcgraw-Hill Osborne Media; 

ISBN: 0078822343
*/

<!--
  Program 4-4
-->
<html>
<head>
<script language="JavaScript">
<!--
function showElements(f) {
  var formElements = "";
  for (var n=0; n < f.elements.length; n++) {
      // Build a string containing each element:
      formElements += n + ":" + f.elements[n"\n";
  }
  alert("The elements in the form '" 
        f.name + 
        "' are:\n\n" +
        formElements);
}
//-->
</script>
</head>
<body>
<form name="ExampleForm">
<table border=0>
<tr>
 <td>
  <input name="cb1" type="checkbox" checked>Option 1<br>
  <input name="cb2" type="checkbox">Option 2
 </td>
</tr>
<tr>
<td>Name:</td>
<td><input type="text" size=45 name="fullname"></td>
</tr>
<tr>
 <td>Address:</td>
 <td><textarea name="ta"></textarea></td>
</tr>
<tr>
 <td>
  <input type="button"
         value="See elements"
         onClick="showElements(this.form)">
 </td>
</tr>
</form>
</table>
</body>
</html>
Related examples in the same category
1.  Formats, verifies and recover the contents of HTML forms
2.  Count forms in a document
3.  Access an item in a collection








Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.