Re: newbie dynamic dropdowns
Try the following. I can't see the difference between your if and else but no doubt there should be, I'm guessing the param gp shouldn't be 1 in the else.
Code:
<%
Dim sSP :sSP=Request.Form("SP")
Dim sVal
Dim sDesc
%>
<select name="SP" onChange="MM_jumpMenu('parent',this,0)">
<option>Select a Company</option>
<%do Until r.EOF
tt=r("companyname")
'response.write(tt)
id=r("id")
If gp = 1 Then
sVal = "adduser.asp?c=" & id & "&gp=1"
sDesc=tt
Else
sVal="adduser.asp?c=" & id & "&gp=1"
sDesc=tt
End If
Response.Write "<option value=""" & sVal & """"
If sSP=sVal Then Response.Write " selected=""selected"""
Response.Write ">" & sDesc & "</option>" & vbNewLine
r.MoveNext
loop%>
Re: newbie dynamic dropdowns
thanks a bunch! i'll let you know what happened when i go back to work next week :)
Re: newbie dynamic dropdowns
I'm sad to say that code yielded the exact same results as I had before -- still goes back to "Select Company"
Re: newbie dynamic dropdowns
make sure you have removed the selected from this line
VB Code:
<option [HL="#FFFF00"]selected[/HL]>Select a Company</option>
The easiest way to check is to view source and see what the html output is for the select list
I suspect you'll have the first option as above then the option you previously selected saying selected="selected" <-- if you implemented it in the way I suggested.
If not then what you should do is write out the value of sSP and then each val from your select list as you loop through and see if there is a match
Re: newbie dynamic dropdowns
I have taken your advice, still, what perplexes me (and thanks by the way), is that it selects the correct value from the database, but no matter what it generates the selected line with "Select Company", even when that line is completely removed from the code. This makes no sense at all. :eek2: