I am trying to retain a selected value in the dropdown after posting the page.
Description of scenario
These are my dropdown options
<select id="JqueryDDownForAvailableFrom">
<option value="17:00">17:00</option>
<option value="18:00">18:00</option>
</select>
Before submitting the Page, I am assigning the value to a variable using the below line.
var selectedVal=$("#JqueryDDownForAvailableFrom")
After submitting the page the same dropdown should retail its value.
I do not want to change in options, but want to display the selected value after posting the form.
I have used this one:
This is adding anew option to the dropdown.
$('#JqueryDDownForAvailableTo').append('<option selected="true" value='+selectedValTo+'>' +selectedValTo + '</option>')
I have used this one
This is not selecting the selected value:
$('#JqueryDDownForAvailableTo').val(selectedValTo);
I tried to find on google but failed.
Any assistance please.
for getting selected value
for setting selected value
hope this helps you