How to convert the onchange="this.form.submit()" to jQuery format?
<form action="process.php" method="post">
<select name="qty" onchange="this.form.submit()">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</form>
I got a problem because some of browser will do nothing on the process.php if use onchange="this.form.submit()"
Let me know..
You don’t need to do anything. Whilst you can change
this.form.submit()to$(this).closest('form').submit(), this will have no effect (apart from being slightly less readable) as all jQuery will do with that will be to callthis.form.submit().If you have a problem with submitting the form from plain JavaScript, you will still have the same problem submitting it with jQuery. What exactly is that problem?
In any case you should generally not use auto-submitting select boxes. They break keyboard accessibility (since IE fires
onchangeprematurely from keyboard use) and they interact poorly with the back button.