tags:

views:

45

answers:

5

I have this form in my html:

    <form action="/awe/ChangeTheme/Change" method="post">

    <select id="themes" name="themes">
    ...
    <option value="blitzer">blitzer</option>
    </select>

    <input type="submit" value="change" />

    </form>

anybody knows how to submit it when a value is selected in the 'themes' dropdown ?

+1  A: 
$(function() {
    $('#themes').change(function() {
        $('form').submit();
    });
});
Darin Dimitrov
+1  A: 
$('#themes').change(function(){
    $('form').submit();
});
Rocket
+1  A: 

I recommend using the longhand bind method because it has the same effect as the shorthand supplied by the other answers, but you can add additional events if need be without having to change your code.

$("#themes").bind("change", function() {
  $("form").trigger("submit");
});
Kamikaze Mercenary
+2  A: 

The other solutions will submit all forms on the page, if there should be any. Better would be:

$(function() {
    $('#themes').change(function() {
        this.form.submit();
    });
});
RoToRa
+1  A: 

In case your html contains more than one form

$(function() {
  $('#themes').bind('change', function(e) {
    $(this).closest('form')
           .trigger('submit')
  })
})
xPheRe