JQuery - which form was submitted?
Posted
by
OneMostFrustratedChap
on Stack Overflow
See other posts from Stack Overflow
or by OneMostFrustratedChap
Published on 2011-02-09T15:22:42Z
Indexed on
2011/02/09
15:25 UTC
Read the original article
Hit count: 215
Hello,
I have a page of products and for each of them, I want to have a form that uses AJAX to update the session. I've done this bit - just providing background.
I use the product's ID to create a different form class and name for each form, so each form is called something like this_form_name_567 and the next would be this_form_name_568 and so on.
There is a submit button per form. I'm having trouble figuring out
a) which event is best to use so that the correct form will be identified when a submit button is clicked,
b) once clicked, how to then make sure the correct value is taken from a hidden field (unique ID) within the submitted form so that I can populate a line of code such as: $.post("compare_response.php", {compare_this: $("#compare_this").val()}, function(data){ }
Any help would be greatly appreciated.
Thank you
© Stack Overflow or respective owner