Alert entire contents of form


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function showVals() {
  2. theForm = document.getElementById('myform');
  3. theStr = '';
  4. for (i=0; i < theForm.elements.length; i++) {
  5. ele = theForm.elements[i];
  6. theStr += ele.name + ' : ' + ele.value + "\n";
  7. }
  8. alert (theStr);
  9. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.