How to Build an Array from check boxes, to build product list 
Author Message
 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/



Fri, 19 Sep 2003 12:03:39 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Accessing the Built-in Labels list (product number)

2. Modify a list box after page build?

3. Help Required for Building New Document from Check Boxes

4. Clearing/Setting a check box with SendKeys in built-in dialog

5. how can i build arrays of text boxes?

6. Q: Building picture box control array.

7. how can i work/build with arrays of text boxes

8. building a list box on the fly using data off a type (structure)

9. New Product For Easily Building Web Applications From Access

10. Get Product Version Information for Builds with Letters

11. Automate Your Software Builds with Visual Build 2.0

12. Automate Your Software Builds with Visual Build 2.0

 

 
Powered by phpBB® Forum Software