Example4 : using getElementById in a form

The code

function processFormData(name_attr)
{

  var mail_format_elements = document.getElementsByName(name_attr);
 
  var message = "The form has the following elements with " +
        " the 'name' attribute = '" + name_attr + "': \n\n";

  for (i=0; i<mail_format_elements.length; i++) {
    message += mail_format_elements[i].tagName +
      ' element with "id" attribute = "' +
      mail_format_elements[i].getAttribute("id") + '"\n';
  }
 
  alert(message);
 
}

Download the code here: getelementbyid-form-sample.zip

Back to article: using getElementById

  • Digg
  • del.icio.us
  • Netscape
  • Reddit
  • StumbleUpon
  • Technorati
  • YahooMyWeb

HTML Forms
HTML Form Tutorial
The Form Tag
The Form Submit Button
Form design software

Javascript Form Handling
  Basics
Using getElementById to get the elements in a form
Set value of form element using JavaScript
Get value of form element using JavaScript
Handling multiple forms using JavaScript
JavaScript reset/clear a form
  Advanced
JavaScript Form Validation
Submitting a form using JavaScript
Can JavaScript Email a Form?
Switching the form action field dynamically
JavaScript Button

JavaScript Popup Windows
The window.open method
The window.close method
More ...

 
.   Copyright © 2003-2008 Simfatic Solutions. All rights reserved.