Filling in Dropdown list from DB

S

Steve Grosz

I'm going through the Buyens book FP2003 Inside Out, and am trying to get a
dropdown box to fill with info from the database.

In the book, here is the ASP code that goes in the text box field:
<%=Request("RestName")%>

When I run the page, it prints just the same way, doesn't display the DB
fields.

Any ideas?

Steve
 
T

Thomas A. Rowe

If you are trying to populate the database from the database you must first
generate a recordset from the database, then you have to loop the result to
populate the dropdown.

A "request" statement is used when passing data via a form, query string,
etc. not when grabbing data returned from a database query, which would look
similar to the following:

<%=recordset("fieldname")%> Below StateRS is the name of the recordset.

Now to populate a drop down, you code would look similar to the following:

<SELECT size="1" name="State">
<% while NOT StateRS.EOF %>
<option value="<%=StateRS("StateID")%>"><%=StateRS("State")%></option>
<%
StateRS.MoveNext
wend
StateRS.Close
%>
</SELECT>

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
M

MD WebsUnlimited.com

Hi Steve,

In the DRW, in the fourth panel of the wizard, select the drop down and
select "Dropdown list -- one record per item."
 
S

Steve Grosz

Jim Buyens said:
"Steve Grosz" <[email protected]> wrote in message

I'd like to help you, but it's not clear from your message what you're
trying to accomplish and how you're going about it. For example:

1. Are you using the Database Results Wizard to fill the
dropdown box, or are you writing your ASP code?

I am using the DBRW to fill in the dropdown box, trying to avoid writing my
own ASP if possible.
2. How does the text box containing <%=Request("RestName")%> relate
to
the drop-down list?

3. Did you save the page with an .asp filename extension?

Yes, I did save it with a ASP file extension
4. Are you using an http:// URL to browse the page from a Windows
Web server?

I have published to page to a W2k Server with 2002 server extensions, and am
browsing to that page once its published.
 
J

Jim Buyens

1. So, the drop-down list is coming up empty; is that it?

2. In your original question, you stated:
In the book, here is the ASP code that goes in the text
box field: <%=Request("RestName")%>
How does this related to the rest of your question?

3. In your original question, you also stated:
When I run the page, it prints just the same way,
doesn't display the DB fields.
How does printing figure into all this?

4. How do you want the finished Web page to work, exactly?

5. Is the page somewhere tht I can browse? If so, what's the URL?

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 
X

xmas

Hi Steve,

I don't know if you ever got it working But if not take a look here....

http://www.xmas-i-am.com/how_to_filter_drop-down.htm

Hope this helps...

Here are some links that might be of some use to you also...

http://www.xmas-i-am.com/links.htm

xmas
=======================
| I'm going through the Buyens book FP2003 Inside Out, and am trying to get
a
| dropdown box to fill with info from the database.
|
| In the book, here is the ASP code that goes in the text box field:
| <%=Request("RestName")%>
|
| When I run the page, it prints just the same way, doesn't display the DB
| fields.
|
| Any ideas?
|
| Steve
|
|
 

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

Top