|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Combo box sets up Second Combo box
<i><b>Originally posted by : Keith Malatesta (Malatesta@mediaone.net)</b></i><br />Thank you all for helping me with my Update problem... <br /><br />I have another one. I am trying to set up two combo boxes where the first Displays Distinct from ProductCategory.ProductCategory. I want the second box ProductSubCategory to show Distinct based on what was selected for ProductCategory.<br /><br />The first box displays correctly...when the page returns, the SQL statement is correct, but the second box has only "All" in it.<br /><br />If anyone can offer any assistance, It would be greatly appreciated!<br /><br />Code:<br /><br /><html><br /><br /><head><br /><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><br /><meta name="GENERATOR" content="Microsoft FrontPage 4.0"><br /><meta name="ProgId" content="FrontPage.Editor.Document"><br /><title>New Page 1</title><br /><%@ LANGUAGE="VBScript" %><br /></head><br /><br /><body><br /><%<br /> Dim prodCatStr, prodsubcatStr<br /> Dim catRS, subcatRS<br /> Dim Conn, SQLProdCat, SQLProdSubCat<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("ProdCat")<br /> prodSubCatStr = Request.Form("ProdSubCat")<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 /> <br /> End If<br /> <br /> Response.Write SQLProdSubCat<br />%><br /> <form action="ProdCatSubCat.asp" Method="POST" name="SelectProdList"><br />Product Category <br /> <select name="ProdCat" 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="SubCat" 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("SubCat") Then<br /> Response.Write "<option selected "<br /> Else<br /> Response.Write "<option "<br /> End If <br /> Response.Write "value=""" & SubCatRS("SubCat") & """>"<br /> Response.Write SubCatRS("SubCat") & "</option>"<br /> SubCatRS.MoveNext<br /> Loop<br /> SubCatRS.close<br /> End If<br />%><br /> </select><br /><br /></form><br /><br /><br /><br /></body><br /><br /></html><br />
|
|
#2
|
|||
|
|||
|
<i><b>Originally posted by : Keith (malatesta@mediaone.net)</b></i><br />I figured at least part of...stupid typo...<br /><br />Now when the Script returns, the correct info is displayed in the second combo, but if you try to select it, it comes up as "All".<br /><br />Any thought?<br /><br /><br />------------<br />Keith Malatesta at 9/27/2000 12:54:54 PM<br /><br />Thank you all for helping me with my Update problem... <br /><br />I have another one. I am trying to set up two combo boxes where the first Displays Distinct from ProductCategory.ProductCategory. I want the second box ProductSubCategory to show Distinct based on what was selected for ProductCategory.<br /><br />The first box displays correctly...when the page returns, the SQL statement is correct, but the second box has only "All" in it.<br /><br />If anyone can offer any assistance, It would be greatly appreciated!<br /><br />Code:<br /><br /><html><br /><br /><head><br /><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><br /><meta name="GENERATOR" content="Microsoft FrontPage 4.0"><br /><meta name="ProgId" content="FrontPage.Editor.Document"><br /><title>New Page 1</title><br /><%@ LANGUAGE="VBScript" %><br /></head><br /><br /><body><br /><%<br /> Dim prodCatStr, prodsubcatStr<br /> Dim catRS, subcatRS<br /> Dim Conn, SQLProdCat, SQLProdSubCat<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("ProdCat")<br /> prodSubCatStr = Request.Form("ProdSubCat")<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 /> <br /> End If<br /> <br /> Response.Write SQLProdSubCat<br />%><br /> <form action="ProdCatSubCat.asp" Method="POST" name="SelectProdList"><br />Product Category*** <br /> <select name="ProdCat" 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="SubCat" 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("SubCat") Then<br /> Response.Write "<option selected "<br /> Else<br /> Response.Write "<option "<br /> End If <br /> Response.Write "value=""" & SubCatRS("SubCat") & """>"<br /> Response.Write SubCatRS("SubCat") & "</option>"<br /> SubCatRS.MoveNext<br /> Loop<br /> SubCatRS.close<br /> End If<br />%><br /> </select><br /><br /></form><br /><br /><br /><br /></body><br /><br /></html><br />
|
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Combo box sets up Second Combo box |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|