Dropdowns populated from Databases

D

Dave

Can multiple dropdowns be used in a form where the dropdowns are populated
from different databases?

I have tables for class locations and course name.

I would like to have these populated form databases using asp.

Is this possible?

Thanks
 
T

Thomas A. Rowe

Yes, different tables, different database can be done but require hand coding.

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

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
D

Dave

Do you know of an example somewhere?
Thanks

Dave
Thomas A. Rowe said:
Yes, different tables, different database can be done but require hand coding.

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

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
T

Thomas A. Rowe

If you are using the FP database component, someone else that use it will provide you with the
instructions, as I only do hand coding.

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

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
J

Jim Buyens

-----Original Message-----
Can multiple dropdowns be used in a form where the
dropdowns are populated from different databases?
Yes.

I have tables for class locations and course name.

I would like to have these populated form databases
using asp.

Is this possible?

Yes.

If you wish, you can do this entirely in FrontPage, using
the Database Results Wizard. On page 4 of the DRW, specify
Dropdown List - One Record Per Item, and then specify the
fields that provide the display values (i.e. CourseName)
and the submit values (i.e. CourseCode).

Am I correct in thinking that when the visitor selects a
different class name, you want to reload the list of class
locations? If so, you'll need to add a script like the
following to the <head> section.

<script>
function autoSub(){
document.forms[0].submit();
}
function setAutoSub(){
for (i = 0;
i <= document.forms[0].CourseCode.options.length - 1;
i++) {
if (document.forms[0].CourseCode.options.value ==
"<%=request("CourseCode")%>"){
document.forms[0].CourseCode.selectedIndex = i;
break;
}
}
document.forms[0].CourseCode.onchange=autoSub;
}
</script>
</head>
<body onload="setAutoSub();">

The autoSub function submits the form. The setAutoSub
function first sets the selection in the drop-down list to
that of the last form submission, and then configure the
CourseCode drop-down list to call the autoSub function
whenever the visitor changes the selected item.

The dropdown list for course location wouldn't need these
extra scripts, but it *would* need to use the CourseCode
field as a selection criteria, as in

SELECT *
FROM CourseLocations
WHERE CourseCode = '::CourseCode::'

Finally, don't configure the form's Submit button as a
submit button. Instead, configure it as an ordinary
pushbutton with an onclick attribute like this:

<input type="button" onclick="document.forms
[0].action=process.asp;document.forms[0].submit();">

This will submit the form to your processing page rather
than recycling the page to reflect a new course code.

There's still a loose end here, because when the page runs
initially, the second dropdown list won't "know" what
course code to query. If the first course code is always
the same, you could hard-code it as a default in the
second dropdown list box. Otherwise, you would have to rig
something up to submit the form automatically the first
time it displays.

Doing all this in hand-written ASP code may actually be
easier, but only if you have some programming skills.

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)
|/---------------------------------------------------
*----------------------------------------------------
 

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