tags:

views:

17

answers:

3

http://fsc.no/timeplan_rommen_197.html

When you select a different week (uke) from a dropdown on the right or trainer from the left dropdown above the schedule, it submit automatically . You don't need to click Submit(Vis).

How do you submit when you just select an option from a dropdown list?

Can it be done with jquery?

Thanks in advance.

A: 

Yes, you can do by triggering the .submit() event, like this:

$("select").change(function() {
  $(this).closest("form").submit();
});

Or, call the native event:

$("select").change(function() {
  $(this).closest("form")[0].submit();
});

The above examples would make it happen with any <select> element, just give it a different selector like an ID, for example: $("#mySelect"), or a class if you have multiple, for example:

<select class="autoSubmit">

And bind it using:

$(".autoSubmit").change(function() { ...
Nick Craver
A: 
$("#myddl").change(function(){
$("#myform").submit();
});
steven spielberg
A: 

Yes you can submit a form using jquery code. in your case you need to submit the form when the user selects a new value in the drop down. this can be done as follows:

$('#dropdown-id').change(function() {
  $('#form-id').submit();
});
Abdel Olakara