I have to populate the values to drop down box from SQL. Classic ASP is the language I need to use. I was able to populate it; however, I am not being able to keep the selected value in the drop down. I kept the value "selected" after "option value" inside the loop but the issue after doing this was: all the prior options keep on loading (selecting) in drop down until the one I selected comes in the list. Can anyone suggest/comment where/what am I missing?
Categories:<select name="menu" onChange="if(options[selectedIndex].value != 0){location='test.asp?list=bybrand&brandID=' + options[selectedIndex].value + '', exit=false;}">
<OPTION value=0 selected>-- SELECT --</OPTION>
<% dim rs
SQL = "SELECT DISTINCT(brand) as brand FROM tblprdt"
SET rs=objConn.Execute(SQL)
IF NOT (rs.BOF and rs.EOF) THEN
WHILE NOT rs.EOF
Response.Write "<option value=""" & replace(rs("brand")," & ","@") & """ selected >" & rs("brand") & "</option>"
rs.MoveNext
WEND
ELSE
Response.Write "<option >No categories available</option>"
END IF
rs.close
SET rs = nothing
%>
</select>