Posted By

vasilije on 10/04/08


Tagged

javascript jquery


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

shaho
mdrisser
artions
Hollow
maxvee8
seanpowell
jillella


get form input fields with jQuery


 / Published in: JavaScript
 

  1. $('#myForm').submit(function() {
  2. // get all the inputs into an array.
  3. var $inputs = $('#myForm input, #myForm textarea, #myForm select');
  4.  
  5. // not sure if you wanted this, but I thought I'd add it.
  6. // get an associative array of just the values.
  7. var values = {};
  8. $inputs.each(function(i, el) {
  9. values[el.name] = $(el).val();
  10. });
  11.  
  12. });

Report this snippet  

You need to login to post a comment.