asp.net mvc - Sending form with Select List -


i using code post value of selected item view controller

@using (html.beginform()) {         @html.dropdownlistfor(model => model.myvar, (selectlist)viewdata["list"])         <button name="button" value="valider">valider</button>  } 

is there way send value when selection change in select list (without need click on button) ?

yes can via jquery, on dropdown selection change post form via jquery:

add id drop down:

@html.dropdownlistfor(model => model.myvar, (selectlist)viewdata["list"], new { id="someid"}) 

and write jquery event:

$(function(){      $("#someid").change(function(){          $(this).closest("form").submit(); // post form     });     }); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -