PDA

View Full Version : Dynamically set the selected property of the select tag


delobetc
06-20-2006, 09:13 PM
I have a select tag with options like below"

<SELECT NAME="Type" >
<OPTION Selected="true" VALUE='News'>News</option>
<OPTION VALUE='Events'>Events</option>
<OPTION VALUE='Generic'>Generic</option>
</select>

The problem I am havinging is that when I click on my submit button and it reloads the form the selected property always resets itselft and the first option is the one visible to the user.

I want whichever option the user selects when they hit the submit button to be the option that has the selected="true" property set (in other words, the option visible to the user in the drop down.

So in the example above, if the user selected "Events" and hit submit, Events would be the option showing in the drop down list, not News.

pj_anf
06-21-2006, 12:33 PM
remove your "selected=true" statement. Also, you'll probably want to give the user a cookie to remember the value if they are leaving the page for the submission.