Javascript select onchange='this.form.submit()'
Solution 1:
You should be able to use something similar to:
$('#selectElementId').change(
function(){
$(this).closest('form').trigger('submit');
/* or:
$('#formElementId').trigger('submit');
or:
$('#formElementId').submit();
*/
});
Solution 2:
My psychic debugging skills tell me that your submit button is named submit
.
Therefore, form.submit
refers to the button rather than the method.
Rename the button to something else so that form.submit
refers to the method again.
Solution 3:
If you're using jQuery, it's as simple as this:
$('#mySelect').change(function()
{
$('#myForm').submit();
});
Solution 4:
There are a few ways this can be completed.
Elements know which form they belong to, so you don't need to wrap this
in jquery, you can just call this.form
which returns the form element. Then you can call submit()
on a form element to submit it.
$('select').on('change', function(e){
this.form.submit()
});
documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement