i want to Convert the below given jsp code in asp.
<select size="1" name="s" style="width: 150">
<option <%=s.equals("abc") ? "selected" : "" %> value="abc">abc</option>
</select>.
Please guide.
| SitePoint Sponsor |
i want to Convert the below given jsp code in asp.
<select size="1" name="s" style="width: 150">
<option <%=s.equals("abc") ? "selected" : "" %> value="abc">abc</option>
</select>.
Please guide.




Code ASP:<select size="1" name="s" style="width: 150" value="abc"> <option <% if [put option value here]="abc" then response.write( " selected " ) %> >abc</option> </select>.
iT DOESNT WORKS.
I have exactly this code.
<% SQL ="Select City From City order By City"
Set rs = sconn.Execute(SQL)%>
<select name="Location" size="1">
<option >- Select -</option>
<%while not rs.EOF%>
<option value=<%=rs(0)%>><%=rs(0)%></option>
<%RS.MoveNext
wend%>
</select>
I have two combo box like this..now suppose i save selected item from two combo in the database..
now i want that when i click on update button the two combox box should come with that saved selected value along all the another values also...
Please guide how to make changes in this.




before it can be shown as selected you must have two things
1] a comparison check to find a match and
2] the word "selected" placed into the option tag
Code ASP:<select name="Location" size="1"> <option >- Select -</option> <% SQL ="Select City From City order By City" Set rs = sconn.Execute(SQL) while not rs.EOF 'initialize value for select '------------------------------- vSelected = "" ' make a comparison '------------------------- if rs(0) = "[your comparison value must be provided here]" then vSelected = " selected " 'place selected word into option tag if match exists '---------------------------------------------------------------- %> <option <%=vSelected%>value="<%=rs(0)%>"><%=rs(0)%></option> <% RS.MoveNext wend %> </select>
Bookmarks