Hi all ASP newbie here:
First - I know this has been answered a billion times on this site and I've read some of the posts but unfortunitely my current working knowledge of ASP classic is limited as I've just moved over from client/server to web development so some of the posts I have been trying to interpret on this subject are so complex its not making sense to me so I thought I would start my own post and hope someone is willing to help out.
Basically, I want to create an example that I can learn from and adapt for future uses. I want to be able to select an item in one list box and have that then update/change the list of available items in the second list box. for this simple example I have created 2 tables in sql server with the following properties:
table: test_productmain
PK: ProductID
field: ProductName
table: test_productsub
PK: ProDetailID
FK: ProductID
field: ProDetailName
these two tables are joined 1-many on ProductID... Simple enough. Now I have created a select box that queries the table: test_productmain, loops the recordset and populated the drop down fields. Here is the code I am using:
CODE.................
<html>
<head>
</head>
<body>
<form name="testlist" method="post" action="testlist.asp">
<select name="selectmain">
<%
connstr = "DRIVER=SQL Server;SERVER=Jerry;DATABA
SE=Jerryda
tabase;UID
=xxxxxxx;P
ASSWORD=xx
xxxxxxxxx"
sql = "Select ProductID, ProductName From dbo.test_productmain"
set conn = Server.CreateObject("ADODB
.Connectio
n")
conn.Open connstr
set rs = Server.CreateObject("ADODB
.Recordset
")
rs.open sql,conn, 3
do until rs.eof
for j = 1 to rs.fields.count - 1
%>
<option value="<%= rs.fields("ProductID").val
ue %>"><%= rs.fields("ProductName").v
alue %></option>
<%
next
rs.movenext
loop
rs.close
conn.close
set rs = nothing
set conn = nothing
%>
</select>
</form>
</body>
</html>
CODE END.......................
..........
..
This works great and populates the main list/select box. My question is then, based on what I have above - what are the next steps to create another listbox which will be able to retrieve the ProductID value from the main listbox and use that as part of the Where clause in the SQL...? I'm making this work 500 points as I am really appreciative to anyone who can set the rest of this up for me as I'm at a loss. Also - my javascript is even worse then my vbscript - note: this solution needs to me in vbscript for asp classic as this is not a .net app! and any javascript may need a little hand holding :)
If this were client/server I could crank this out in 3 seconds!!! so frustrated :)
Appreciate all help!
Kev