<select id="abc">
<option value="1">1</option>
<option value="2">3</option>
<option value="3">4</option>
<option value="4">5</option>
<option value="5">5</option>
</select>
<select id="cde">
<option value="1">1</option>
<option value="2">3</option>
<option value="3">4</option>
<option value="4">5</option>
<option value="5">5</option>
</select>
<script>
(function(){
var selects = document.querySelectorAll('select');
for (var i = 0, select; select = selects[i]; i++) {
if (localStorage[select.id] !== undefined) {
select.selectedIndex = localStorage[select.id];
}
select.onchange = function() {
localStorage[this.id] = this.selectedIndex;
}
}
})()
</script>
|