Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Option selected

Reply
Thread Tools

Option selected

 
 
Ram Raju
Guest
Posts: n/a
 
      02-04-2004
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


 
Reply With Quote
 
 
 
 
Ray at
Guest
Posts: n/a
 
      02-04-2004
The first item will be selected by default, will it not? What happens when
you load the page?

Ray at work

"Ram Raju" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Aaron Bertrand - MVP
Guest
Posts: n/a
 
      02-04-2004
Ummm, first option IS selected by default.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/




"Ram Raju" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
TomB
Guest
Posts: n/a
 
      02-04-2004
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
%>

"Ram Raju" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need help to fill textboxes from a selected item in datagrid-selected index changed. mldardy ASP .Net 0 09-28-2010 02:59 PM
selected=selected in the center of option list John HTML 5 03-01-2010 08:30 PM
Selected ListItem in DropDownList does not appear selected Nathan Sokalski ASP .Net 0 10-05-2008 10:29 PM
DropDownList 2 always returns Selected = 0 for all items - even selected item Iain ASP .Net 3 12-11-2006 11:07 AM
Dynamically update SELECTED option in option list Mark Kolber Javascript 4 01-01-2005 02:07 PM



Advertisments