Looking for a JavaEE Architect or Potential Tech Co-Founder?
Please don't hesitate to contact me.

Jquery copy form values into another form

Recently I have a requirement to have two form on a single page.

Why? It's because I have a search form that query records from the database with the aid of ajax. Then another form to generate a report based from the filters specified in the first form.

So when the submit button from the search form is pressed, it populates the fields on the second form with values from the first form. And here's how I did it in jquery:

$(':input[name]', "#searchForm").each(function () {
  if ($(this).attr('name') != 'SubmitButton') {
  $('[name=' + $(this).attr('name') + ']', "#generateReportForm").val($(this).val());
  }
})   
Jquery copy form values into another form Jquery copy form values into another form Reviewed by Edward Legaspi on Tuesday, July 19, 2011 Rating: 5

No comments:

Powered by Blogger.