-
maintaining a SELECT value in the SELECT tag??
Hi
I have a <select> defined in a form.
My question is , how do I maintain the value of the select after my button has been pressed.
if was a input field, the value would be maintained using value='request.form(select)' but htis is not possible witha select.
cheers.
Steve
-
You mean to retain the state of the control if the form is reloaded? If so you have to set "selected" against the relevant option in the select e.g.
<select>
<option value="1">x</option>
<option value="2" selected>y</option>
<option value="3">z</option>
</select>
How bets to do this depends on your programming language and the source of the data for the select options. Ideally you will be able to loop through the options and then the code to test if the current option is selected can be written just once. e.g. (pseudocode)
while(getoption)
if({value} = {formvalue})
selected = " selected"
else
selected = ""
end if
output(<option value="{value}"{selected}>{text}</option>);
end while
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules