JSFiddle - React, Tailwind, and code Playground
HTML
<FORM NAME="form1">
<select id="country-select" NAME="country" SIZE="1">
<OPTION VALUE="non-value">Select Country
<OPTION VALUE="chile">Chile
<OPTION VALUE="colombia">Colombia
<OPTION VALUE="bolivia">Bolivia
</select>
</FORM>
<script type="text/javascript">
(function(){
var sel = document.getElementById('country-select'),
country,
max,
i;
if (!sel) {
return;
}
if (localStorage && localStorage.country) {
country = localStorage.country;
if (country !== 'non-value') {
opts = sel.options;
max = opts.length;
for (i = 0; i < max; i++) {
if (opts[i].value === country) {
location = country;
return;
}
}
}
}
sel.addEventListener('change', function() {
var val = sel.options[sel.selectedIndex].value;
if (val !== 'non-value') {
if (localStorage) {
localStorage.country = val;
}
location = val;
}
});
})();
</script>