Well, one way is to rewrite you page:
Code:
<select name="fruit">
<%
fruitopts = Array("apple","banana","orange")
priorFruit = RS("fruit")
For f = 0 To UBound(fruitopts)
fruit = fruitopts(f)
If fruit = priorfruit Then sel = " SELECTED " Else sel = ""
Response.Write "<option " & sel & ">" & fruit & "</option>" & vbNewLine
Next
%>
</select>
The other way is to use
JS code. Problem is, you have to delay the use of the
JS code until the <FORM> is fully loaded, at least.
But anyway:
Code:
<script>
function matchPriorSelect( sel, value )
{
for ( var o = 0; o < sel.options.length; ++o )
{
var opt = sel.options[o];
var optval = opt.value;
if ( optval == "" ) optval = opt.text;
if ( optval == value )
{
opt.selected = true;
return;
}
}
}
</script>
and then somehow you have to do something like this:
<body onload="matchPriorSelect(document.FormName.fruit, '<%=RS("fruit")%>' );">
Except you probably don't want to dump that into the onload, in case you are using various
JS libraries that could overwrite it, so probably you just want to dump the call at the end of your page, after the </form> tag.