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