Option selected

R

Ram Raju

Hi All,

I am displaying few values in a List box. I would like to put first
item as selected by default.
i.e <option value="some value" selected>Name</option>

Here is my code.

<SELECT size=15 id=select1 name=select1>
<% do while not Rs.EOF %>
<Option value=<%=Rs("value")%>><%= Rs("Name") %></Option>
<%
Rs.MoveNext
loop
%>
</SELECT>


Can anybody please help me.

Thanks in Advance.
Ram
 
R

Ray at

The first item will be selected by default, will it not? What happens when
you load the page?

Ray at work
 
T

TomB

Do you mean when the form is posted, you want to display the value selected
in the Select box?


<%
Do while not rs.eof
Response.write "<option value=""" & RS.Fields("value").value &
""""
if RS.Fields("value").value=Request.form("select1") then
Response.write " selected"
end if
Response.write ">" & RS.Fields("Name") & "</option>" & vbCrlf
Rs.MoveNext
Loop
%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top