I have a set of forms which is dynamically created.
<form action='test.php' method='post' name='addtocart' id='form1'>
<input class="qty" type="text" size="3" name="quantity" value="1">
<input class="btnStandard" type="button" name="submit" value="Add to Cart">
</form>
<form action='test.php' method='post' name='addtocart' id='form2'>
<input class="qty" type="text" size="3" name="quantity" value="1">
<input class="btnStandard" type="button" name="submit" value="Add to Cart">
</form>
By clicking the button with class btnStandard
the corresponding form will get submit.
My jquery code
$(document).ready(function(){
$(document).on('click', '.btnStandard', function(event){
var formId = $(this).parent("form[name='addtocart']").attr('id');
alert(formId); //gives the form id
$('form#'+formId).submit();
});
});
But the form is not submitting.
EDIT
I missed it: I edited the Question as suggested in comment. Still the form is not get submit, but the alert is working.