asp.net mvc - jQuery <select> value of <form> always null -
i've done many times , it's cinch, there's wrong here , can't see problem. when selection made dropdown list, .value null. know better that. can't see problem. see problem in code?
in _layout.cshtml i'm calling controller action returns partial view:
@{html.renderaction("languagelistpartial", "account");}
the partial view:
@html.dropdownlistfor( x => x.selectedlanguage, model.languages, new { @class = "form-control } )
the dropdown renders fine:
html:
<form method="post" action="/account/listpartial"> <select name="selectedlanguage" id="selectedlanguage"> <option value="en-us">english</option> <option value="fr-ca">francais</option> <option value="pt-br">portugues</option> <option value="es-mx">espanol</option> </select> </form> <div id="test"></div>
jquery called on change:
@scripts.render("~/bundles/jquery") @scripts.render("~/bundles/jqueryui") @scripts.render("~/bundles/bootstrap") @rendersection("scripts", required: false) <script type="text/javascript"> $(document).ready(function () { $(function () { $('#selectedlanguage').on('change', function () { var = $(this).val(); $('#test').load("/account/testpartial/" + a); return false; }); }); }); </script> </body> </html>
try this:
<script type="text/javascript"> $(document).ready(function () { $(function () { $('#selectedlanguage').on('change', function () { var = $(this).val(); $('#test').load("/account/testpartial/" + a); return false; }); }); }); </script>
Comments
Post a Comment