javascript - Display selected value in dropdown menu -
i have drop down list this:
<select id="ddllanguage" name="culture"> <option value="null" >language:</option> <option value="ar-jo">arabic</option> <option value="en-us">english</option> <option value="fr-fr">french</option> <option value="es-cl">spanish</option> </select>
if select "arabic",the drop down list should display "arabic". getting "language".
edit
i got answer using viewbag
script:-
<script type="text/javascript"> $(function () { $('#ddllanguage').val("@viewbag.msg"); $('#ddllanguage').change(function () { $('#currentculture').val($(this).val()); $(this).parents("form").submit(); }); }); </script>
in controller have set value of viewbag.msg.
viewbag.msg = ddllanguage
try code
$('#ddllanguage').change(function(){ alert( $(this).find('option:selected').text()); });
Comments
Post a Comment