I am trying to set up a HTML select box where the user can enter morning, noon and night. I also want this to editable if the user returns to the site.
If for example the user were to choose night, and then returned to the page a day later, when they open the page, the page would first fetch the users data and store it in a variable called “when”
When the select box loads i would like to to to determine the value of “when” (morning, noon or night) and set the select box to that value.
I can set the default to always return to morning. i.e.: <option value=”1″ SELECTED>Morning</option> but that won’t work for me. I have tried the following to use javascript but it isn’t working.
Any guidance would be greatly appreciated.
[code]
<script>
var when = Noon;
// I TRIED BOTH OF THE FOLLOWING:
document.getElementById(‘times’).options[“Noon”].selected = true;
document.getElementById(‘times’).options[2].selected = true;
</script>
*
<form name=”myForm” id=”myForm”>
****<select name=“times” id=“times”>
***** * *<option value=”1″>Morning</option>
***** * *<option value=”2″>Noon</option>
* * * ****<option value=”3″>Night</option>
****</select>
</form>