Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

drop box "selected" problem 1

Status
Not open for further replies.

scottRen

Technical User
Feb 4, 2005
69
0
0
CA
Hi i'm response.writing a drop box, here the section of the page for it:

.Write "<select NAME='li_start_dt_month'>"

For ll_temp = 1 to 12
.write "<option value=" & ll_temp
.write ">" & MonthName( ll_temp, True ) & "</option>" & vbcrlf
Next
.Write "</select>"

I have aa=response.QueryString("month") where aa=2 (thats Febuary)

I would like to have this aa value (ranging from 1-12) selected in the drop down. So what ever the aa value is, in the html view the drop down is already selected for that value.

currently the above produces this "view source" html code:

<select NAME='li_start_dt_month'>
<option value=1>Jan</option>
<option value=2>Feb</option>
<option value=3>Mar</option>
<option value=4>Apr</option>
<option value=5>May</option>
<option value=6>Jun</option>
<option value=7>Jul</option>
<option value=8>Aug</option>
<option value=9>Sep</option>
<option value=10>Oct</option>
<option value=11>Nov</option>
<option value=12>Dec</option>

would like it like where the value of aa that corresponds to the month is selected, so for aa=2 this:

<select NAME='li_start_dt_month'>
<option value=1>Jan</option>
<option value=2 SELECTED>Feb</option>
<option value=3>Mar</option>
<option value=4>Apr</option>
<option value=5>May</option>
<option value=6>Jun</option>
<option value=7>Jul</option>
<option value=8>Aug</option>
<option value=9>Sep</option>
<option value=10>Oct</option>
<option value=11>Nov</option>
<option value=12>Dec</option>

thanks, 've been playing with this without any luck
 
You didnt mention what you already tried so I will suggest the most obvious:

For ll_temp = 1 to 12
.write "<option value=" & ll_temp
[red] IF (aa = ll_temp) THEN Response.Write " SELECTED " [/red]
.write ">" & MonthName( ll_temp, True ) & "</option>" & vbcrlf
Next
 
yes i already tried that without luck:

For ll_temp = 1 to 12
.write "<option value=" & ll_temp
If (a2 = ll_temp) Then
.Write " SELECTED"
End If
.write ">" & MonthName( ll_temp, True ) & "</option>" & vbcrlf
Next
 
tr this
Code:
    For ll_temp = 1 to 12
         .write "<option value=""" & ll_temp &""""
          If (clng(a2) = clng(ll_temp)) Then
         .Write " SELECTED"
         End If
         .write ">" & MonthName( ll_temp, True ) & "</option>" & vbcrlf    
     Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top