I have been given this task to complete but I'm not a asp developer so I was wondering if anyone out there could help.
What I need to achieve is to produce a selection filter combo box or filter for searching products. There are a total of three fields in the form. The first is a drop down select option box where the user picks a brand. I'm using a onchange event to pass the value via a url to populate the next field which is also a drop down select option field populated based on the value of the first selection. I'm using the same process to again pass a value via the url to a third drop down select field which then when a selection is made creates a url of the target page.
<--select>Brand</select-->
<--select>Series</select--> Value passed by Brand selection
<--select>Printer</select--> Value passed by Series selection
<user is taken to url from selection of value passed by Series selection>
I need this to use the same method but not to refresh the page, I think I'm right that I'm going to have to use jquery to get the same result with a page refresh. Does anyone know of maybe a guide or tutorial that can show how to accomplish this? Or if anyone has an idea of which way to go I'd really appreciate it.
Here's the code I have presently which works but uses a page refresh.
ThanksCode:<% varBrand=Request.QueryString("brand") varSeries=Request.QueryString("series") varProd=Request.QueryString("prod") if len(varBrand) > 0 then set rstCat = server.CreateObject("adodb.recordset") set rstCat = oConn.Execute("SELECT TOP 1 CID,Category,CatShort FROM [Categories] WHERE CID = " & varBrand & " ORDER BY CatShort DESC;") If rstCat.EOF Then Response.Write "Error1" Else varCID = rstCat("CID") varCN = rstCat("Category") varCatShort = rstCat("CatShort") End If End If if len(varSeries) > 0 then set rstCat = server.CreateObject("adodb.recordset") set rstCat = oConn.Execute("SELECT TOP 1 * FROM [PrinterType] WHERE PTypeID = " & varSeries & " ORDER BY PTypeTit DESC;") If rstCat.EOF Then Response.Write "ERROR" Else varPrintType = rstCat("PTypeTit") End If End If dim varInkCategories: varInkCategories = GetInkCategories() %> <form method="post" name="f1" action=""> <select style="width:220px;" name="brand" onchange="window.location.href='./?brand='+this.value"> <% if len(varBrand) > 0 then %> <option selected value=""><%=varCatShort%></option> <% else %> <option selected value="">- Select a printer brand -</option> <% end if For LoopCounter = 0 To Ubound(varInkCategories,2) Response.Write "<option value='" & varInkCategories(0, LoopCounter) & "'>" & varInkCategories(2, LoopCounter) & "</option>" Next %> </select> <br /> <% if len(varBrand) > 0 Then set rstCat2 = server.CreateObject("adodb.recordset") set rstCat2 = oConn.Execute("SELECT * FROM PrinterType WHERE CID = " & varBrand & " ORDER BY PTypeTit") If rstCat2.EOF Then Else Do While Not rstCat2.EOF ArrCat2 = rstCat2.GetRows() Loop Const PTypeID = 0 Const PTypeName = 2 End If %> <form method="post" name="f2" action=""> <!--<select style="width:280px;" name="series" onchange="window.location.href='./?brand=<%'=varBrand%>&series='+this.value">--> <select style="width:280px;" name="series" onchange="window.location.href='./?brand=<%=varBrand%>&series='+this.value"> <% if len(varSeries) > 0 then %> <option selected value=""><%=varPrintType%></option> <% else %> <option selected value="" >- Select a printer series -</option> <% end if For LoopCounter = 0 To Ubound(ArrCat2,2) Response.Write "<option value='" & ArrCat2(PTypeID, LoopCounter) & "'>" & ArrCat2(PTypeName, LoopCounter) & "</option>" 'Response.Write ArrCat1(CShort, LoopCounter) & "<br>" Next %> </select> <br /> <% end if if len(varSeries) > 0 Then varNoType = 0 set rstCat3 = server.CreateObject("adodb.recordset") set rstCat3 = oConn.Execute("SELECT DISTINCT dbo.Printers.PName FROM dbo.Printers INNER JOIN dbo.Categories ON dbo.Printers.CID = dbo.Categories.CID INNER JOIN dbo.ItemLookup ON dbo.Printers.PID =dbo.ItemLookup.PID INNER JOIN dbo.Cartridges ON dbo.ItemLookup.CartID = dbo.Cartridges.CartID WHERE dbo.Printers.PTypeID = " & varSeries & " ORDER BY dbo.Printers.PName DESC") If rstCat3.EOF Then varNoType = 1 Else Do While Not rstCat3.EOF ArrCat3 = rstCat3.GetRows() Loop End If varCat2 = LCASE(Trim(Replace(varCN," ","-"))) %> <select style="width:280px;" name="frmPrinter" id="frmPrinter" onchange="if (this.selectedIndex > 0) location.href=this[this.selectedIndex].value;"> <% if (varNoType) = 1 Then %> <option selected value="">No printers available</option> </select> </form> <% else %> <option selected value="">- Select a printer -</option> <% For LoopCounter = 0 To Ubound(ArrCat3,2) varProd = LCASE(Trim(Replace(ArrCat3(arrPTN, LoopCounter)," ","-"))) Response.Write "<option value='http://www.mysite.com/" & varCat2 & "/" & varProd & "'>" & ArrCat3(arrPTN, LoopCounter) & "</option>" Next End If %> </select> </form> </p> <% end if %>



Reply With Quote

Bookmarks