ASP - Logic for populating menu based on previous menu selection

windows

Guest
I've got a DB with a table containing rain gauges and a table that contains rain sensors that are located on those gauges, and gauges can contain more than one sensor.

The first drop down will allow the user to select the gauge from the DB, and the second drop down should take that information and pull the appropriate sensors from the other table based on the selection. Hopefully, this much is clear so far.

The code I have so far:
<form method="post" action="createreport.asp">
Water Gauge:
<select name="Gauge">
<%
dim rsgauge, sql
set rsgauge = server.CreateObject("ADODB.recordset")
sql = "SELECT DISTINCT STATION_ID FROM XC_SITES WHERE ENABLED='Y' ORDER BY STATION_ID"
rsgauge.Open sql, cn, adLockReadOnly
Do While Not rsgauge.EOF %>
<option value="<%=rsgauge.Fields("STATION_ID") %>"> <%=rsgauge.Fields("STATION_ID")%></option>
<% rsgauge.MoveNext
Loop
rsgauge.close
cn.close
set cn = nothing
%>
</select>

<select name="Sensor">
<%
dim rssensor, sql2
set rssensor = server.CreateObject("ADODB.recordset")
sql2 = "SELECT SENSORNAME, STE_STATION_ID FROM XC_SITESENSORS WHERE STE_STATION_ID = STATION_ID AND STATION_ID=" & rsgauge.Fields("STATION_ID") & " ORDER BY STE_STATION_ID"
rssensor.Open sql2, cn, adLockReadOnly
Do While Not rssensor.EOF %>
<option value="<%=rssensor.Fields("SENSORNAME") %>"><%=rssensor.Fields("SENSORNAME") %></option>
<% rssensor.MoveNext
Loop
rssensor.close
cn.close
set cn = nothing
%>
</select>
</form>

How would I go about writing the logic that tells the page not to pull the second until the user first select which gauge they would like the sensors for?you would have to make a nother trip to the server... otherwise that would not work ...And advice on how to get this started?No one?

Would something like this work:

<% If Response.Form(鎻媢age_DropDown? <> 鎽
 
Back
Top