From what I understand, the default treatment for return false is:
<input type="submit" onclick="return false" />
However in my code I would like to have a submit button run a separate js function onclick
which will give ajax output based on which radio button the user selected.
But since I'm using ajax and my js function to take care of the output, I want the submit button to return false.
But if I am already using onclick
to point to the function:
<input type="submit" onclick="jsfunction()" />
where do I put return false?
Can I have 2 onclick
statements?
The other option I would imagine is that if I know I am not going to be submitting the form regardless of which value the function returns, that it shouldn't be a submit button at all?
But if that's the case, is there a button I can code in html that looks the same as submit but doesn't have the submit property?
try to add your method (jsmethod) to your form onsubmit handler like this
<form onsubmit="jsfunction(); return false;">
and remove the input onclick handler.
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