I have added a select box to the top of a working page - the working page shows Products which belong to a Department passed via. URL
The select box I have added - shows printers in the dropdown which belong to the Department Name.
What I would like to do now is filter the products based on the selected item in the drop down.
I have a table called [1digiPrinter] - which displays the PrinterID, Manufacturer and PrinterName
and
a table called [1digiPrinterProduct] which has PrinterID and ProductID so that they can be mapped.
So in essence the filter needs to say - show me all Products where the ProductID = [1digiPrinterProduct].Prod
uctID and PrinterID = [1digiPrinterProduct].Prin
terID (although I know at this stage, I'm not passing the PrinterID out of the select, only the PrinterName
Basically - how would I filter the products like this but more importantly - how can I action this filter everytime someone selects a different printer? (Resubmit to same page - ideally automatically without having to click the submit button)
Note - there are two seperate forms on this page. The other form does a comparison of 2 or more products.
If you need any more info - give me a shout.
I hope you can help.
Thanks in advance!
__________________________
__________
__________
__________
__________
__________
__________
____
<%
If PrinterName = "" Then
Dim MyConn, RS, connStr
Response.Write "Selection = <b>" & PrinterName & "</b><br>"
Set MyConn=Server.CreateObject
("ADODB.Co
nnection")
connStr=""
SQL = "Select Distinct PrinterName From [1digiPrinter] Where Manufacturer = '"&rs1digiDepartment("Depa
rtmentName
")&"'"
MyConn.Open connStr
Set RS = MyConn.Execute(SQL)
%>
<p>
<form method = "Post">
<select name="PrinterName">
<option selected>--Select PrinterName--
<%While Not RS.EOF%>
<option value="<%=RS("PrinterName"
)%>">
<%=RS.Fields("PrinterName"
)%>
<%
RS.MoveNext
Wend
RS.Close
MyConn.Close
Set RS = Nothing
Set MyConn = Nothing
%>
</select>
<input type="submit" name="save" value="Show me Ink Cartridges for this printer">
</p>
<p>
<input type="hidden" name="PrinterName" size="20" value="<%=PrinterName%>">
</p>
</form>
<%End If%>
<!-- Display the description -->
<img src="/images/compare.gif" alt="Click two or more checked boxes and then click on Compare at the bottom to compare products" width="200" height="95">
<%
' Create an ADO database connection
set db1digiProduct = server.createobject("adodb
.connectio
n")
' Create the record set
set rs1digiProduct = server.CreateObject("adodb
.recordset
")
' Open the connection using our ODBC file DSN
db1digiProduct.open ""
' Build the sql statement to retrieve the products in
' the department. The ID of the department is passed in.
sql = "execute [1digi_RetrieveDeptProduct
s] " & request("DepartmentID")
' Execute the SQL statement and retrieve the record set
set rs1digiProduct = db1digiProduct.Execute(sql
)
' We are going to rotate the images from left
' to right.
%>
&n
bsp;
&nbs
p;
<form action="compare.asp" method="post" target="_blank">
<table width="100%" height="129" border="0">
<tr>
<%
Flag=0
' Loop through the products record set
do until rs1digiProduct.EOF
' Retrieve the product information to be displayed.
ProductName = rs1digiProduct("ProductNam
e")
ProductImage = rs1digiProduct("ProductIma
ge")
ProductID = rs1digiProduct("ProductID"
)
ProductPriceexcvat = rs1digiProduct("ProductPri
ceexcvat")
ProductPriceIncVAT = rs1digiProduct("ProductPri
ceIncVAT")
' rotate the
' product images from left to right.
if Flag = 1 Then
Flag=1
%>
<!-- Build the link to the product information. -->
</tr><tr>
<td width="100%" height="110" align="left" valign="top">
<div align="left">
<p align="left"> <strong><%=ProductName%></
strong>&nb
sp; &
nbsp; 
; &nb
sp; &
nbsp; 
; &nb
sp; &
nbsp; 
; &nb
sp; &
nbsp; 
; &nb
sp; &
nbsp; 
; &nb
sp;<strong
><%=format
currency(P
roductPric
eExcVAT)%>
ex. VAT <%=formatcu
rrency(Pro
ductPriceI
ncVAT)%> inc. VAT</strong> &n
bsp;
</p>
<p align="center"><a href="product.asp?ProductI
D=<%=Produ
ctID%>">
</a> &n
bsp;<a href="product.asp?ProductI
D=<%=Produ
ctID%>"><i
mg src="images/products/<%=Pr
oductImage
%>" border="0" align="middle"></a>
<a href="additem.asp?ProductI
D=<%=Produ
ctID%>&Qua
ntity=1&Pr
oductName=
<%=Product
Name%>&Pro
ductpricei
ncvat=<%=P
roductPric
eincvat%>&
ProductShi
pping1stCl
ass=<%=rs1
digiProduc
t("Product
Shipping1s
tClass")%>
&ProductSh
ipping2ndC
lass=<%=rs
1digiProdu
ct("Produc
tShipping2
ndClass")%
>&ProductS
hipping1st
ClassR=<%=
rs1digiPro
duct("Prod
uctShippin
g1stClassR
")%>&Produ
ctShipping
SD=<%=rs1d
igiProduct
("ProductS
hippingSD"
)%>"><img src="/images/addtobasket.g
if" alt="Add to basket" width="100" height="24" border="0" align="right"></a>
</p>
<a href="product.asp?ProductI
D=<%=Produ
ctID%>"></
a>
<input type="checkbox" name="ProductID" value="<%=ProductID%>">
Compare <hr></div>
</td>
<% else %>
<!-- Build the link to the product information. -->
<td width="100%" height="110" align="left" valign="top">
<div align="left">
<p align="left"> <strong><%=ProductName%></
strong>&nb
sp; &
nbsp; 
; &nb
sp; &
nbsp; 
; &nb
sp; &
nbsp; 
; &nb
sp; &
nbsp; 
; &nb
sp; &
nbsp; 
; &nb
sp;<strong
><%=format
currency(P
roductPric
eExcVAT)%>
ex. VAT <%=formatcu
rrency(Pro
ductPriceI
ncVAT)%> inc. VAT</strong> &n
bsp;
&nbs
p;
</p>
<p align="center"><a href="product.asp?ProductI
D=<%=Produ
ctID%>">
</a> &n
bsp;<a href="product.asp?ProductI
D=<%=Produ
ctID%>"><i
mg src="images/products/<%=Pr
oductImage
%>" border="0" align="middle"></a>
<a href="additem.asp?ProductI
D=<%=Produ
ctID%>&Qua
ntity=1&Pr
oductName=
<%=Product
Name%>&Pro
ductpricei
ncvat=<%=P
roductPric
eincvat%>&
ProductShi
pping1stCl
ass=<%=rs1
digiProduc
t("Product
Shipping1s
tClass")%>
&ProductSh
ipping2ndC
lass=<%=rs
1digiProdu
ct("Produc
tShipping2
ndClass")%
>&ProductS
hipping1st
ClassR=<%=
rs1digiPro
duct("Prod
uctShippin
g1stClassR
")%>&Produ
ctShipping
SD=<%=rs1d
igiProduct
("ProductS
hippingSD"
)%>"><img src="/images/addtobasket.g
if" alt="Add to basket" width="100" height="24" border="0" align="right"></a>
</p>
<a href="product.asp?ProductI
D=<%=Produ
ctID%>"></
a>
<input type="checkbox" name="ProductID" value="<%=ProductID%>">
Compare
<hr>
</div>
</td>
<%
Flag=Flag+1
end if
' Move to the next row
rs1digiProduct.movenext
loop
%>
</tr></table>
<p>
</p><input type="submit" value="Compare">
</form>
<a href="product.asp?ProductI
D=<%=Produ
ctID%>">
</a>
__________________________
__________
__________
__________
__________
__________
__________
_____