Is there a reason why I shouldn’t use:
onChange="this.form.submit()"
instead of
$(function () {
$("#dropdown").live("change keyup", function () {
$("#theform").submit();
});
});
Someone said it the onChange method shouldn’t be used. I’m trying to find out the logic behind it.
The script basically submits the form on dropdown option change.
Functionally, there is little difference.
The idea behind moving things out of inline
onChange=...attributes is to decouple your JavaScript from your markup. Having JavaScript mixed inline with your markup leads to ugly pages which are difficult to maintain and debug.Ideally, you should have a clear separation between JavaScript, CSS and HTML. Your functionality, style and structure should be as independant and decoupled as possible.