Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop down box

Status
Not open for further replies.

ChristianX

Programmer
Mar 17, 2003
14
0
0
GB
Good evening all,
i am stil having persisting problems in trying to
figure out how to create a drop down box that gets its
contents from a database table.

the table i have is called Book: BookID, Title, Publisher

What i want to do is create a drop down box that gets all the
titles from the Book table and put them in the drop down.

Ive only started learning ASP since monday so go easy on me guys!

heres the code ive tried to write so far:

<!--#include file=&quot;Clssfd.asp&quot;-->
<html>
<head>
<title>Dynamic Drop-Down Menu</title>
</head>

<body>

<%
Dim rsBook
Set rsBook = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsBook.Open &quot;Book&quot;, objConn, adOpenForwardOnly, adLockOptimistic, adCmdTable
Do while not rsBook.EOF
Response.write &quot;<OPTION value= &quot;&quot; & Title & &quot;&quot;></OPTION>&quot;
rsBook.MoveNext
Loop
%>

</body>
</html>
 
Do while not rsBook.EOF
Response.write &quot;<OPTION><%=rs(&quot;Title&quot;)%></OPTION>&quot;
rsBook.MoveNext
Loop

As you had it it was looking for a variable called Title and not a field in the recordset. Also if the value you want passed is the same as the value that is gonna be inthe drop down you dont need to set a 'value='. You would (or I do) use the value aspect when you want to put a friendly description in the drop down box but the value you want passed is for example a DB field e.g. email is the field name in a database but in the drop down box you want it to say E-Mail so your option tag would look like this
<option value=&quot;email&quot;>E-Mail</option>

Hope that helps
Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top