|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Selecting Values in a Drop Down Box - DATABASE
<i><b>Originally posted by : Bipasha (bipasha@hotmail.com)</b></i><br />This is the code I have, to display a drop down box with values from 1 to 100<br /><br /><select name="reports"><br /> <option selected value="1">1</option><br /> <% for i = 2 to 100 %><br /> <option value="<%=i%>"><%=i%></option><br /> <% next<br /> i = i + 1<br /> %><br /><br />Suppose I insert (value=45) for reports into a database. The next time I view this drop down box for that particular report....I want 45 to be selected (highlighted) instead of 1 (which is the default)<br /><br />I tried doing this:<br />------------------<br /><select name="reports"><br /> <% for i = 1 to 100 <br /> If Session("val") = i then %><br /> <option selected value="<%=Session<br /> ("val")%>"><%=Session("val")%><br /> </option><br /> <% Else %><br /> <option value="<%=i%>"><%=i%</option><br /> <% End If<br /> next<br /> i = i + 1<br /> %><br /><br />But this doesnt seem to be working. Can somebody please help me with this problem?? Thank U in advance.<br /><br />
|
|
#2
|
|||
|
|||
|
<i><b>Originally posted by : Troels Majlandt (troels@majlandt.dk)</b></i><br />This should do the trick.<br /><br /><br /> <td width="20%" valign="top" align="left" bgcolor="#DDEEFF"><font color="#000080"><b>Vision</b></font></td><br /> <td width="80%" valign="top" align="left" bgcolor="#FFFFCC" colspan="3"><nobr><select NAME="vision" SIZE="1" style="font-family: Verdana; font-size: 8 pt; color: #000080"><br /> <%DO WHILE NOT rs3.EOF%><br /> <option value="<%=rs3("Visions_ID")%>" <%if rs3("Visions_ID") = rs("Visions_ID") Then response.write " selected " end if%>><%=rs3("Vision")%></option><br /> <%rs3.MoveNext<br /> LOOP<br /> RS3.Close%><br />
|
![]() |
| Viewing: ASP Free Forums > Programming > .NET Development > Selecting Values in a Drop Down Box - DATABASE |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|