I have a several forms that are output from a database on the same page. It works fine when I don\'t use ajax. When I use Jquery it will only work for the first form. Could
The problem is that selectors like $('.hardSoft')
will select several elements (since there are multiple forms) and then .val()
will take the value of the first. You could try finding the form using .parents('form')
and then taking its children .children('.hardSoft')
.
$('.updateSubmit').live('click', function() {
var currentForm = $(this).parent();
var hardSoft = currentForm.children('.hardSoft').val();
// ... etc.
On the other hand, this is a rather common task. Take a look at the jQuery Form plugin, which allows you to do the same using much less code. It's probably also more reliable and has several features that you might want to use later in your project.