
October 10th, 2000, 12:03 PM
|
|
Contributing User
|
|
Join Date: Dec 2002
Posts: 14,575
  
Time spent in forums: < 1 sec
Reputation Power: 22
|
|
|
Simple Question for ASP Pro
<i><b>Originally posted by : Keith Malatesta (malatesta@mediaone.net)</b></i><br />Hello, <br /><br />I am have some difficulty with a script that populated multiple listboxes. The first (Category) works fine, and populates the second (SubCategory) correctly. The problem lies when I select the SubCategory, the form submits but does not return the SubCategory selection. I want the selection to hold, so I can pass the prodsubcatStr via query string.<br /><br />Anyone?<br /><br />Here is my code:<br /><br /><%@ LANGUAGE="VBScript" %><br /><br /></head><br /><br /><body><br /><%<br /> Dim prodCatStr<br /> Dim prodsubcatStr<br /> Dim catRS, subcatRS<br /> Dim Conn, SQLProdCat, SQLProdSubCat<br /> Dim strProduct_ID<br /> <br /> strProduct_ID = Request.QueryString("Product_ID")<br /> <br /> '//*** CONNECT TO STOREFRONT ACCESS DATABASE *** <br /> DSN_Name = Session("DSN_NAME")<br /> Set Conn = Server.CreateObject("ADODB.Connection")<br /> Conn.Open DSN_Name<br /> <br /> '//*** READ FORM PARAMETERS ***<br /> prodCatStr = Request.Form("Category")<br /> prodSubCatStr = Request.Form("ProdCatSubCat")<br /> <br /><br /> '//*** DEFINE ALL SQL QUERIES ***<br /> SQLProdCat = "SELECT DISTINCT ProductCategory FROM ProductCategory" <br /> If prodCatStr <> "" Then <br /> SQLProdSubCat = "SELECT DISTINCT ProductSubCategory FROM ProductCategory " & _<br /> "WHERE ProductCategory.ProductCategory = '" & prodCatStr & "'"<br /> <br /> End If<br />%><br /><br />Please change the Category and SubCategory for product: <br /> <form action="CatSub_update.asp?Product_ID=<%=strProduct_ID%>" Method="POST" name="SelectProdList"><br /><input type="text" name="Product_ID" size="20" value="<%=strProduct_ID%>"><br /><p><br />Product Category <br /> <select name="Category" size="1" onChange="document.forms[0].submit()"><br /> <option value="">All</option><br /><%<br /> '//*** PRODUCT CATEGORY DROP-DOWN LIST BOX *** <br /> Set catRS = Server.CreateObject("ADODB.Recordset") <br /> Set catRS = Conn.Execute(SQLProdCat) <br /> Do While not catRS.EOF<br /> If prodCatStr = catRS("ProductCategory") Then<br /> Response.Write "<option selected "<br /> Else<br /> Response.Write "<option "<br /> End If <br /> Response.Write "value=""" & catRS("ProductCategory") & """>"<br /> Response.Write catRS("ProductCategory") & "</option>"<br /> catRS.MoveNext<br /> Loop<br /> catRS.close<br />%><br /> </select><br /><br><br>SubCategory <br /> <select name="SubCategory" size="1" onChange="document.forms[0].submit()"> <br /> <option value="">All</option><br /><% <br /> '//&&& SubCategory DROP-DOWN LIST BOX ***<br /> If prodCatStr <> "" Then<br /> Set SubCatRS = Server.CreateObject("ADODB.Recordset") <br /> Set SubCatRS = Conn.Execute(SQLProdSubCat) <br /> Do While not SubCatRS.EOF<br /> If ProdSubCatStr = SubCatRS("ProductSubCategory") Then<br /> Response.Write "<option selected "<br /> Else<br /> Response.Write "<option "<br /> End If <br /> Response.Write "value=""" & SubCatRS("ProductSubCategory") & """>"<br /> Response.Write SubCatRS("ProductSubCategory") & "</option>"<br /> SubCatRS.MoveNext<br /> Loop<br /> SubCatRS.close<br /> End if<br />%><br /> </select> <br /></p><br /><p><br /> <a href="catsub_update_resp.asp?Product_ID=<%=strProduct_ID%>Category=<%=ProdCatstr%>SubCategory=<%=prodsubcatStr%>"> Update</a><br /></p><br /></form><br /></body><br /></html><br /><br /><br />
|