Help with Jquery and multiple forms on a page.
Posted
by Will
on Stack Overflow
See other posts from Stack Overflow
or by Will
Published on 2010-06-08T12:07:37Z
Indexed on
2010/06/08
12:12 UTC
Read the original article
Hit count: 165
jQuery
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 anyone point me in the right direction please?
Jquery.....
$('.updateSubmit').live('click', function() {
var id = $('.id').val();
var hardSoft = $('.hardSoft').val();
var brand = $('.brand').val();
var subCat = $('.subCat').val();
var subSubCat = $('.subSubCat').val();
var tProduct = $('.tProduct').val();
var description = $('.description').val();
var quantity = $('.quantity').val();
var price = $('.price').val();
var tCondition = $('.tCondition').val();
var featured = $('.featured').val();
var theData = 'id=' + id + '&hardSoft=' + hardSoft + '&brand=' +
brand + '&subCat=' + subCat +
'&subSubCat=' + subSubCat + '&tProduct=' + tProduct
+'&description=' + description +
'&quantity=' + quantity + '&price=' + price + '&tCondition=' +
tCondition + '&featured=' + featured;
$.ajax ({
type: 'POST',
url: '/updateGrab.php',
data: theData,
success: function(aaa) {
$('.'+id).append('<div class="forSuccess">'+aaa+'</div>');
} // end success
}); // end ajax
return false;
}); // end click
and my php form......
while ($row = $stmt->fetch()) {
echo " <form action='http://www.wbrock.com/updateGrab.php'
method='post' name='".$id."'>
<input type='hidden' class='id' name='id' value='".$id."' />
Hardware/Software
<input type='text' class='hardSoft' name='hardSoft'
value='".$hardSoft."' />
Brand
<input type='text' class='brand' name='brand' value='".$brand."' />
Sub-category
<input type='text' class='subCat' name='subCat'
value='".$subCat."' />
Sub-Sub-Cat
<input type='text' class='subSubCat' name='subSubCat'
value='".$subSubCat."' />
Product
<input type='text' class='tProduct' name='tProduct'
value='".$tProduct."' />
Description
<input type='text' class='description' name='description'
value='".$description."' />
Qty
<input type='text' class='quantity' name='quantity'
value='".$quantity."' />
Price
<input type='text' class='price' name='price' value='".$price."' />
Cond
<input type='text' class='tCondition'
name='tCondition'value='".$tCondition."' />
Featured
<input type='text' class='featured' name='featured'
value='".$featured."' />
<input type='submit' id='".$id."' class='updateSubmit'
name='updateSubmit' value='Update' />
</form>
<span class='".$id."'></span>
"; // end echo
} // end while loop from database
This is the first time I've posted here so sorry if its not in the right format. Thanks in advance for the help.
© Stack Overflow or respective owner