This should be trivial, but I am not getting it :\
HTML
<form id="myform" action="#">
<input type="submit" value="Submit" />
<a href="#" onclick="$('myform').submit()">Submit</a>
</form>
JS (Prototype)
$('myform').observe('submit', function(e) {
alert('submitted!');
e.stop();
});
Why the submit is only triggered with the submit via input? Shouldn't the submit event be triggered with $('myform').submit() also?
JSFiddle: http://jsfiddle.net/d8BdM/
Change the form like this:
<form id="myform" action="">
<input type="submit" value="Submit" id="sub_but" />
<a href="#" onclick="$('sub_but').click();">Submit</a>
</form>
And keep the other code; i tested in your fiddle and works.
Saludos ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With