473,322 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Option selected

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
Jul 19 '05 #1
4 3171
The first item will be selected by default, will it not? What happens when
you load the page?

Ray at work

"Ram Raju" <ra*****@lycos.com> wrote in message
news:uu*************@tk2msftngp13.phx.gbl...
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

Jul 19 '05 #2
Ummm, first option IS selected by default.

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


"Ram Raju" <ra*****@lycos.com> wrote in message
news:uu*************@tk2msftngp13.phx.gbl...
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

Jul 19 '05 #3
"Ram Raju" <ra*****@lycos.com> wrote in message
news:uu*************@tk2msftngp13.phx.gbl...
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>


You could use some sort of flag to indicate that it's the first item. Also,
you should surround your attribute values in quotes.

<select size="15" id="select1" name="select1">
<%
Dim firstOption
firstOption = True

Do While Not Rs.EOF
Response.Write "<option value=""" & Rs("value") & """"
If firstOption = True Then
Response.Write " selected"
firstOption = False
End If
Response.Write ">" & Rs("Name") & "</option>"
Rs.MoveNext
Loop
%>
</select>

Hope this helps.
Regards,
Peter Foti
Jul 19 '05 #4
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" <ra*****@lycos.com> wrote in message
news:uu*************@tk2msftngp13.phx.gbl...
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

Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: mr_burns | last post by:
hi, using javascript, how do i select an option in a combo box? i have tried looking on the internet but dont really know what i should be searching for. what i want to happen is that when a...
3
by: Iain Hallam | last post by:
Hi. I've been using display:none on the style property of some <option> elements in my forms, which works fine with Mozilla - as expected it removes the option from my dropdown (although it...
8
by: McKirahan | last post by:
Firefox does not reflect selected option via innerHTML How do I get Firefox to reflect selected option values? <html> <head> <title>FFinner.htm</title> <script type="text/javascript">...
3
by: ANTISPAM_garycnew_ANTISPAM | last post by:
What is the simplest way to retain the last option value selected in an html select object using javascript? I am currently using a server-side cgi language to accomplish this task, but it adds...
6
by: artev | last post by:
if I have a select with more options, how I can know if is there an option selected; is necessary a cycle? or is there an inner property?
2
by: Advo | last post by:
Having major issues with this simple task, and I cant work out why its not doing as it should/expected. Basically, ive got a drop down box with the added bit of php: <select name="title"...
1
by: ollielaroo | last post by:
Hi guys, Firstly I did do a search for this one first but I couldn't find anything related in this forum. I am using Dreamweaver MX and trying to build admin pages for an ASP site. My problem is...
2
by: Sebastian Fey | last post by:
hi, how do you select an option using javascript? i tried to setAttribute("selected", "disabled") to disable last selected and setAttribute("selected", "selected") for the newly selected. ...
1
by: bytesFTW99 | last post by:
I have been struggling with this for some time can anyone help out? just trying to have 3 dropdown boxes that fill depending on what is selected, then in some cases click a button and have the second...
3
by: Venturini | last post by:
I am trying to put together a web page where the customer makes choices of products and is then given a total. I am extremely new to Javascript and have managed to get as far as I have from web...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.