I have a problem with dropdown… I hav a drop down on a page and a button save.. When you choose an option of drop down you want.. and click save.. the value goes to DB and stored there.. when you go on this page again… the drop down must show the value you saved previous time… but i have a problem.. when i come to this page.. dropdown don’t show me the correct value.. it shows me the first value.. but when i click on it the option that selected in this menu is right..
I think maybe i need to refresh it or something?
here is js->
<script>
$(document).ready(function() {
var defaultValue = Settings.getDefaultTimespan();
if (defaultValue == $('#opt' + defaultValue).val()) {
$('#opt' + defaultValue).attr('selected','selected');
}
$('#saveBtn').click(function() {
Settings.setDefaultTimespan(parseInt($('#timeSettingsDropList').val()));
});
});
</script>
Here is HTML->>
<div id="timespanSettings">
<table>
<tr>
<td style="width: 15%"><p>Default timespan:</p></td>
<td style="width: 85%"><select name="timeDropList" id="timeSettingsDropList">
<option id="opt0" value="0">6 Minutes</option>
<option id="opt1" value="1">10 Minutes</option>
<option id="opt2" value="2">15 Minutes</option>
<option id="opt3" value="3">30 Minutes</option>
<option id="opt4" value="4">1 Hour</option>
</select></td>
</tr>
</table>
</div>
As you can see.. dropdown shows “6 Minutes” but selcted is “1 Hour”

Not sure if this will work but what about using localStorage? Live Example:
JS:
HTML: