...

View Full Version : Dynamic List/Recordset Question



heprox
02-06-2004, 06:17 PM
I have a page with two list boxes on it (lstType and lstLocation). In "lstType" here are two choices "Store-to-Store" and "Store-to-Warhouse". The "lstLocation" list box needs to be dynamically populated via a database query depending on which one of the two choices the user makes in the "lstType" list box. I have two recordsets created already for the page. Anyone?

heprox
02-06-2004, 06:31 PM
Sorry, I forgot to post the code:


<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/GNR.asp" -->
<%
var sts_lookup = Server.CreateObject("ADODB.Recordset");
sts_lookup.ActiveConnection = MM_GNR_STRING;
sts_lookup.Source = "SELECT STORE_CD, STORE_NAME FROM STORE WHERE STORE_TP_CD ='S' ORDER BY STORE_NAME";
sts_lookup.CursorType = 0;
sts_lookup.CursorLocation = 2;
sts_lookup.LockType = 1;
sts_lookup.Open();
var sts_lookup_numRows = 0;
%>
<%
var stw_lookup = Server.CreateObject("ADODB.Recordset");
stw_lookup.ActiveConnection = MM_GNR_STRING;
stw_lookup.Source = "SELECT STORE_CD, STORE_NAME FROM STORE WHERE STORE_TP_CD ='W' ORDER BY STORE_NAME";
stw_lookup.CursorType = 0;
stw_lookup.CursorLocation = 2;
stw_lookup.LockType = 1;
stw_lookup.Open();
var stw_lookup_numRows = 0;




td><form name="form1" method="post" action="">
<select name="lstType" size="1" id="lstType">
<option value="STS">Store-to-Store</option>
<option value="STW">Store-to-Warehouse</option>
</select>
</form></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><form name="form2" method="post" action="">
<select name="lstLocation" size="1" id="lstLocation">
<%
while (!sts_lookup.EOF) {
%>
<option value="<%=(sts_lookup.Fields.Item("STORE_CD").Value)%>"><%=(sts_lookup.Fields.Item("STORE_NAME").Value)%></option>
<%
sts_lookup.MoveNext();
}
if (sts_lookup.CursorType > 0) {
if (!sts_lookup.BOF) sts_lookup.MoveFirst();
} else {
sts_lookup.Requery();
}
%>
</select>
</form></td>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum