Almost done!
I followed Jim's instruction with the codes and got what I was looking for.
Except for a small detail.
When you make the first search, everything is perfect. I am using only one
page for the three drop down boxes and the query table.
But, when you re-select the choices (Make, Model) the drop down boxes
re-query, yes, but they keep the first set of values until you reselect all
of them.
You can see it at:
http://www.futuraair.com/newtest3byyear.asp
An example:
Fist selection
Make: Acura
Model:Legend
Year:1993 then we have the table with the results. Perfect!
On this same page, change Year: 1995....no problem. Also Great!
But, change Model to VIGOR and take a look at the Year Drop Box, it keeps
the 1995 value from the first search, even though there are not 1995 records
for Vigor.
If you change Make, it happens the same thing with Model and Year. The drop
down boxes repopulate but they keep the first value.
Question: How could I reset the drop down boxes Model and year when the new
search is done?
I'm not 100% sure how you're creating the first drop-down
list, but I suspect you're using the Database Results
Wizard. If so, achieving what you want is going to be
rather convoluted.
First, sue the Wizard to create three drop-down boxes:
Make, Model, and Year.
o When you set up the Model drop-down box, use the
value of the Make form field as a criteria.
o When you set up the Year drop-down box, use the
value of both the Make and Model form fields as
a criteria.
The next problem is the DRW doesn't create drop-down
boxes that preserve their value. So, when the visitor
submits the form, all three drop-down boxes default to
the top selection. To fix this, refer to:
Persisting the Selection in a Drop-Down Box
http://www.interlacken.com/winnt/tips/tipshow.aspx?tip=49
Next, you want the form to submit automatically whenever
the visitor changes the selection in any drop-down box.
In an ordinary drop-down box, you could achieve this by
adding an onchange= attribute. But if you try the same
thing in a DRW-generated drop-down box, the DRW will
clobber your change every time you run the wizard. So
instead, and an onload= attribute to the <body> like this:
<body onload="initHandlers();">
and then add scripting such as the following to the
<head> section:
<script>
function initHandlers(){
document.forms[0].Make.onchange = Make_onchange;
document.forms[0].Model.onchange = Model_onchange;
document.forms[0].Year.onchange = Year_onchange;
}
function Make_onchange(){
document.forms[0].submit();
}
function Model_onchange(){
document.forms[0].submit();
}
function Year_onchange(){
document.forms[0].submit();
}
</script>
The final problem involves getting the form to submit to
itself when the visitor changes a drop-down box
selection, but submit to your query page when the visitor
clicks the Submit button.
One solution is not to use a separate query page; just
put your query DRW on the same page as the drop-down
boxes.
Otherwise change your Submit button from
<input type="submit" value="Submit" name="btnSub"?
to
<input type="button" value="Submit" name="btnSub"
onclick="document.forms[0].action='query.asp';
document.forms[0].submit();">
where query.asp is the name of your query page.
Well, I told you this was going to be rather convoluted.
To my mind, if you can do all this, you can probably
write an ASP or ASP.NET page from scratch that does the
same thing, and it'll be easier to debug and maintain.
But the choice is yours.
If, in fact, you *are* writing your own ASP or ASP.NET
page, then please post again, explain how you're going
about this, and and ask a more precise question.
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)
|/---------------------------------------------------
*----------------------------------------------------
-----Original Message-----
I was able to create three drop down boxes to search on a table and finally
get the results on another page. The web address is
http://www.futuraair.com/AppliCat1byyear.asp
What I want to do now is to have the three drop down boxes on the same page.
Select the first box , which will submit to the same page populating the
second box, keeping the choices open and the selected value on the box.
(This is done)
Then select the second box which will submit to the same page populating the
third box, keeping the choices open for box 1 and 2 and the selected value
on both boxes. (here begin my problem)
Finally select the third box and get the table results. This I know must be
in another page.
But I want to have on the final page the three drop down boxes with all the
choices available in a way that if I want to re-query from the beginning I
can do it from there.
I got to the first part as you can see it at the following address
http://www.futuraair.com/test1byyear.asp
but when I select the second box, the first box loose the value and the
third box will not populate.
Is this possible with asp or I need to go with Java?
Any help will be appreciated.
Thanks
.