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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select boxes: how do I scope, and use form to regenerate page?

Status
Not open for further replies.

fuzzword

Programmer
Jul 24, 2001
8
US
Hi - I'm new to this so please bear with me.

I'm generating an HTML table that is populated with values from an Access database. That's working fine. My next step, though, is to dynamically generate the query using values from 3 select boxes. So I need to regenerate the page each time any of the select boxes is changed. Furthermore, I need to scope the 2nd and 3rd select boxes based on the contents of the first, and the 3rd select box based on the contents of the 2nd.

In other words, the first select box basically chooses which Table, the second chooses the Division and the third chooses the Department (based on Division), then the table is generated. My final HTML generating SQL query works fine, I just need to get the right variables into the query depending on whats in the Select boxes. Phew. Sorry for the wordiness ;)

I hope that makes sense. I'm thinking this must be done using a javascript onChange, but perhaps there's a way just using ASP (perhaps using an ASP equivalent of a select box)?


 
is the relation department-division stored in a database?
why are division and department dependent from table? br
Gerard
 
No - for the 3rd Select box, the query looks something like:

SELECT Department from 1stSelection where Division = 2ndSelection;

I have the query in a subroutine which is passed tableName, fieldName, whereFieldName, whereSelection and creates the recordset based on that.

The tables (which I did not create) differ because one is for a Category Top 10 report, the other is a Division Top 10 report (in the latter, the 2nd dropdown will be "Category" instead of "Division".)

Thansk for following up!
 
Oke, maybe this will help you/ give you an idea:

[test110861.asp]

<%@ Language=VBScript %>
<%

dim cSelRep, cSelCat, cSelDiv
cSelRep = Request.Form(&quot;SelRep&quot;)
cSelCat = Request.form(&quot;SelCat&quot;)
cSelDiv = Request.Form(&quot;SelDiv&quot;)
if (cSelRep=&quot;A&quot; and cSelCat<>&quot;&quot;) then
Response.Write &quot;REPORT = Category top 10, Category = &quot; & cSelCat
Response.end
elseif (cSelRep=&quot;B&quot; and cSelDiv<>&quot;&quot;) then
Response.Write &quot;REPORT = Division top 10, Divison = &quot; & cSelDiv
Response.end
end if
%>

<form method=post action=test110861.asp>
<select name=SelRep onChange=submit();>
<option value=>-Choose report-
<%
Response.Write &quot;<option value=A&quot;
if cSelRep = &quot;A&quot; then Response.Write &quot; selected&quot;
Response.Write &quot;>Category Top 10<option value=B&quot;
if cSelRep = &quot;B&quot; then Response.Write &quot; selected&quot;
Response.Write &quot;>Division top 10</select>&quot;

' No 2nd select if no report
if cSelRep<>&quot;&quot; then
if cSelRep = &quot;A&quot; then
response.Write &quot;<select name=SelCat onChange=submit();>&quot;
response.Write &quot;<option value=>-Choose category-&quot;
response.Write &quot;<option value=10>Category 10&quot;
response.Write &quot;<option value=20>Category 20</select>&quot;
else
response.Write &quot;<select name=SelDiv onChange=submit();>&quot;
response.Write &quot;<option value=>-Choose division-&quot;
response.Write &quot;<option value=30>Division 30&quot;
response.Write &quot;<option value=40>Division 40</select>&quot;
end if
end if

%>
</form>




Now this is all very static. But you can create the <OPTIONS> with a database query of course.


[i'm watching &quot;Bladerunner&quot; now, so off for today ;-) ]
br
Gerard
 
&quot;He say you Brade Runna&quot;

Cheers - have fun - and thanks for the tips... Mike.Myers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top