I have a form with the following:
<form id="my-form" ...>
...
<button type="submit" name="bttnsubmit" value="1">The first button</button>
<button type="submit" name="bttnsubmit" value="2">The last button</button>
</form>
I'd like to detect which triggered the form submit event using just:
$('#my-form').submit(function(){
//psuedo code
if($('[name=bttnsubmit]').val() == 1) {
....
}
});
Obviously that selector will always return the value of the first bttnsubmit element it comes across, so I need some other magic selector or filter or something.
I have seen $('[name=bttnsubmit][clicked=true]')
touted about but that has not yet worked in my attempts...
I could of course resort to $('[name=bttnsubmit]').click()
but would prefer to be able to achieve my goals in the forms submit event.
Any help/tips much appreciated.
click
handler is being ignored in favor of the formsubmit
handler. – Taboret