
How to Build an Array from check boxes, to build product list
===============================================================
Does anyone know how to make the following code easier.. like put it in an
array?
Well, it is probably not easier.. as I am horrible with arrays.. but I am
tired of hand coding all this stuff..
Just assume there are three products from previous page, with a check box to
order it.
Assume names are chkProductOne, chkProductTwo, and chkProductThree
I will try adding quanties later!
Basically, I am guessing the code would have to scan which checkboxes are
checked from the previous page...
then load them in to an array representing the status, value, and price..
and running totals of price?
And based on that gathering, determine which elements to write to the
page...
and put it all in the proper cells...
I know there has to be an better way? Probably more difficult to do.. but..
VBScript would be the language of choice!
==================================================================
Here is the top of the page.....
' COUNTERS
OrderQty = 0 ' For Tracking
OrderAmount = 0.00 ' Dollar Amount Of Order
' SET PRICES FOR PRODUCTS HERE
session("PriceProductOne") = 1995.00
session("PriceProductTwo") = 2995.00
session("PriceProductThree") = 3995.00
' BUILD SHOPPING CART VARIABLES
If request.form("chkProductOne") = "on" then
session("ProductOne")= request.form("chkProductOne")
End If
If request.form("chkProductTwo") = "on" then
session("ProductTwo")= request.form("chkProductTwo")
End If
If request.form("chkProductThree") = "on" then
session("PriceProductThree")= request.form("chkProductThree")
End If
And here is the Body part builds the table of products ordered...
<%' PRODUCTS ORDERED %>
<%If session("ProductOne") <> "" then%>
<tr>
<td align="center"><font face="Arial" size="2"><b>1</b></font></td>
<td><font face="Arial" size="2"><b><img border="0"
src="../images/spacer_w25.gif">Product One</b></font></td>
<td align="right"><font face="Arial"
size="2"><b><%=formatcurrency(session("PriceProductOne"))%></b></font></td>
</tr>
<%Orderamount = Orderamount + session("PriceProductOne")
OrderQty = OrderQty + 1
End if%>
<%If session("ProductTwo") <> "" then%>
<tr>
<td align="center"><font face="Arial" size="2"><b>1</b></font></td>
<td><font face="Arial" size="2"><b><img border="0"
src="../images/spacer_w25.gif">Product Two</b></font></td>
<td align="right"><font face="Arial"
size="2"><b><%=formatcurrency(session("PriceProductTwo"))%></b></font></td>
</tr>
<%Orderamount = Orderamount + session("PriceProductTwo")
OrderQty = OrderQty + 1
End if%>
<%If session("ProductThree") <> "" then%>
<tr>
<td align="center"><font face="Arial" size="2"><b>1</b></font></td>
<td><font face="Arial" size="2"><b><img border="0"
src="../images/spacer_w25.gif">Product Three</b></font></td>
<td align="right"><font face="Arial"
size="2"><b><%=formatcurrency(session("PriceProductThree"))%></b></font></td
</tr>
<%Orderamount = Orderamount + session("PriceProductThree")
OrderQty = OrderQty + 1
End if%>
<%'TOTAL CALCULATIONS
session("OrderQty") = OrderQty
session("subtotal") = OrderAmount * 1.00
If session("CaSalesTax") = "on" then
CaSalesTax = session("subtotal") * .07625
Else
CaSalesTax = session("subtotal") * 0
End if
session("Total") = (session("subtotal") + CaSalesTax +
session("shippingPrice")) * 1.00
%>
Then I write all the variables in a nice table also...
THANKS!!!!
--
Daniel Hughes
http://www.*-*-*.com/