my php create each product by echo on the end is
<form name="addToCartForm">
<input type="hidden" id="inputid" value="'.$id.'"/>
<input type="submit" id="submitbutton" value="Add to cart"/>
</form>
on the website usually is created 10 products dynamicly
So I have 10 buttons with same class or id for each product displayed by php
any idea for a function to send data to cart.php file by post (jquery) without refreshing website. I must send proper id of product in $_POST so cart.php know what have been added.
AND WHY when I added
$(document).ready(function(e) {
$('#submitbutton').click(function(e) {
var pos = $('#inputid').val();
alert(pos);
return false;
});
});
it is working to alert just first button ADD to CART not all
I am new to jquery:)please help
id
. That's just not how theid
attribute is intended to be used. – Blender