Option selected

Discussion in 'ASP General' started by Ram Raju, Feb 4, 2004.

  1. Ram Raju

    Ram Raju Guest

    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
    Ram Raju, Feb 4, 2004
    #1
    1. Advertising

  2. Ram Raju

    Ray at Guest

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

    Ray at work

    "Ram Raju" <> wrote in message
    news:...
    > 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
    >
    >
    Ray at, Feb 4, 2004
    #2
    1. Advertising

  3. Ummm, first option IS selected by default.

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




    "Ram Raju" <> wrote in message
    news:...
    > 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
    >
    >
    Aaron Bertrand - MVP, Feb 4, 2004
    #3
  4. Ram Raju

    TomB Guest

    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" <> wrote in message
    news:...
    > 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
    >
    >
    TomB, Feb 4, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Julien ROUZIERES

    g++ -pg option and -shared option

    Julien ROUZIERES, Dec 21, 2004, in forum: C++
    Replies:
    1
    Views:
    711
    GianGuz
    Dec 21, 2004
  2. Cas
    Replies:
    5
    Views:
    789
    Kevin Jones
    Aug 28, 2006
  3. Kevin Blount

    page.aspx?option - how to detect "option"

    Kevin Blount, Nov 28, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    603
    =?Utf-8?B?RWVyYWo=?=
    Nov 28, 2006
  4. John
    Replies:
    5
    Views:
    986
    dorayme
    Mar 1, 2010
  5. Mark Kolber
    Replies:
    4
    Views:
    340
Loading...

Share This Page