I have the below form that i want to remove the submit button from (or hide it).
<form action="cart.php" method="post">
<input name="quantity" type="text" value="3" size="1" maxlength="2" />
<input name="adjustBtn" type="submit" value="change" />
<input name="item_to_adjust" type="hidden" value="1" />
</form>
In a jQuery file called test.js that i have included in the page i have the bellow that should submit the form when the input field “quantity” has changed, but it does not, i cannot get it to work and i have tried all sorts of form submit functions from other posts on SO. One person even said that if the submit button had a name of submit it would not work but i do not have that.
$(document).ready( function() {
$('#quantity').change(function(){
//$(this).closest("form").submit(); <-- commented out as not working either.
//$(this).closest('form')[0].submit(); <-- commented out as not working either.
$('#adjustBtn').submit();
});
} );
Anyone have any idea why it wont submit the form? I have tested in chrome and IE.
You need to submit the
forminstead of thebutton:Also, you didn’t give an
idto youradjustBtn, thus$("#adjustBtn")won’t work;The same thing happens with
#quantity, that’s why thechangehandler doesn’t get fired, you need to also add theid: