Hi,
I am trying to do a calculation with Arrays. I have a shopping application created that displays the items that the user selects in a table this data comes from an array. The array is populated as the user goes through the site.
I ned to calculate each product by the amount and display it then add up the totals. The code for the page is given below.
The Price is where the quantity * the price will be displayed and the cost is all of the prices added up.
any ideas greatly appreciated.
Thanks
Anne
Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Checkout</TITLE>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type><LINK
href="checkout_files/styles.css" rel=stylesheet>
<META content="MSHTML 5.00.2919.6307" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff>
<!---<CFQUERY NAME="Basket_List" DATASOURCE="products">
SELECT id, description, category, pack_weight, price1, price2, price3, price4
FROM products
</CFQUERY>--->
<CFSET session.basket[ArrayLen(session.basket)][9]=form.quantity>
<FORM name="checkout" action="confirm.cfm" method=post>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0>
<TBODY>
<TR>
<TD bgColor=#999999 class=whitenormal height=20
width=210>&nbsp;&nbsp;Product Description</TD>
<TD align=middle bgColor=#cccccc class=whitenormal width=90>Code</TD>
<TD align=middle bgColor=#999999 class=whitenormal width=50>Category</TD>
<TD align=middle bgColor=#cccccc class=whitenormal width=40>Pack Weight</TD>
<TD align=middle bgColor=#999999 class=whitenormal width=60>Quantity</TD>
<TD align=middle bgColor=#cccccc class=whitenormal width=50>Unit(£)</TD>
<TD align=middle bgColor=#999999 class=whitenormal width=50></TD>
<TD align=middle bgColor=#cccccc class=whitenormal width=60>Cost (£)</TD>
<TD bgColor=#999999 class=whitenormal width=140>&nbsp;</TD></TR>
<TR>
<TD colSpan=9><IMG height=6 src="" width=1><IMG height=6
src="checkout_files/shim.gif" width=1><IMG height=10
src="checkout_files/shim.gif" width=1></TD></TR></TBODY></TABLE>
<CFLOOP index="rowCount" from="1" to="#ArrayLen(session.basket)#" step="1">
<CFOUTPUT>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0>
<TBODY>
<TR>
<TD bgColor=##cccccc class=whitenormal width=210><IMG align=left height=30
src="checkout_files/shim.gif" width=2>&nbsp;#session.basket[rowCount][2]#</TD>
<TD align=middle class=greysm width=90>#session.basket[rowCount][1]#</TD>
<TD align=middle class=greysm width=50>#session.basket[rowCount][3]#</TD>
<TD align=middle class=greysm width=40>#session.basket[rowCount][4]#</TD>
<TD align=middle class=greysm width=60>#session.basket[rowCount][9]#</TD>
<TD align=middle class=greysm width=50>Price</TD>
<TD align=middle class=greysm width=50>&nbsp;</TD>
<TD align=middle class=greysm width=60>Cost</TD>
<TD align=right width=70>
<A
href="detail.cfm"
target=mainFrame><IMG border=0 height=28 name=Image13
src="checkout_files/prod_update.gif" width=67></A> </TD>
<TD align=right width=70><A
href="checkout.cfm"?><IMG
border=0 height=28 name=Image2 src="checkout_files/remove.gif"
width=67></A></TD></TR>
<TR>
<TD colSpan=10><IMG height=5 src="checkout_files/shim.gif"
width=20></TD></TR></TBODY></TABLE>
</CFOUTPUT>
</CFLOOP>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width=750>
<TBODY>
<TR>
<TD bgColor=#cccccc height=20 width=450>&nbsp;</TD>
<TD bgColor=#cccccc class=coralnormal width=100>&nbsp;sub total</TD>
<TD align=middle bgColor=#999999 class=whitenormal width=60>1050.50</TD>
<TD bgColor=#cccccc width=140>&nbsp;</TD></TR>
<TR>
<TD height=5></TD>
<TD height=5></TD>
<TD></TD>
<TD></TD></TR>
<TR>
<TD align=middle class=coralmed height=45 rowSpan=3>Please
Note:<BR>clicking the 'CONFIRM ORDER' button below submits your order, so
if you need to make any changes to your order requirement, please do so
before clicking the button!</TD>
<TD bgColor=#cccccc class=purplenormal height=20>&nbsp;shipping</TD>
<TD align=middle bgColor=#999999 class=whitenormal>30.65</TD>
<TD bgColor=#cccccc>&nbsp;</TD></TR>
<TR>
<TD height=5></TD>
<TD></TD>
<TD></TD></TR>
<TR>
<TD bgColor=#cccccc class=purplenormal height=20>&nbsp;VAT</TD>
<TD align=middle bgColor=#999999 class=whitenormal>26.65</TD>
<TD bgColor=#cccccc>&nbsp;</TD></TR>
<TR>
<TD height=5></TD>
<TD height=5></TD>
<TD></TD>
<TD></TD></TR>
<TR>
<TD height=20>&nbsp;</TD>
<TD bgColor=#cccccc class=coralnormal height=20>&nbsp;Total</TD>
<TD align=middle bgColor=#999999 class=whitenormal height=3>1156.32</TD>
<TD bgColor=#cccccc height=3>&nbsp;</TD></TR></TBODY></TABLE>
<TABLE align=center border=0 cellPadding=2 cellSpacing=0 width=750>
<TBODY>
<TR>
<TD colSpan=4 height=5></TD></TR>
<TR>
<TD bgColor=#cccccc class=header colSpan=4>&nbsp;please enter/check your
details below.....</TD></TR>
<TR>
<TD class=greynormal height=5 width=120></TD>
<TD width=255></TD>
<TD class=greynormal width=120></TD>
<TD width=255></TD></TR>
<TR>
<TD align=right class=greynormal width=120>Name:</TD>
<TD width=255><INPUT name=name size=40> </TD>
<TD align=right class=greynormal width=120>Delivery address:</TD>
<TD rowSpan=3><TEXTAREA cols=36 name=address rows=4 wrap=PHYSICAL></TEXTAREA>
</TD></TR>
<TR>
<TD align=right class=greynormal>Home telephone:</TD>
<TD><INPUT maxLength=25 name=homephone size=25> </TD>
<TD>&nbsp;</TD></TR>
<TR>
<TD align=right class=greynormal>Work telephone:</TD>
<TD><INPUT maxLength=25 name=workphone size=25> </TD>
<TD>&nbsp;</TD></TR>
<TR>
<TD align=right class=greynormal>Fax:</TD>
<TD><INPUT maxLength=25 name=homefax size=25> </TD>
<TD align=right class=greynormal>Post code/Zip code:</TD>
<TD><INPUT maxLength=7 name=pcode size=7> </TD></TR>
<TR>
<TD align=right class=greynormal>Email address:</TD>
<TD><INPUT maxLength=50 name=email size=25> </TD>
<TD align=right class=greynormal>&nbsp;</TD>
<TD>&nbsp; </TD></TR>
<TR>
<TD align=right class=greynormal>Credit card:</TD>
<TD class=greynormal colSpan=3><INPUT CHECKED name=ccard type=radio
value=Mastercard> MasterCard <INPUT name=ccard type=radio value=Visa> Visa
<INPUT name=ccard type=radio value=Switch> Switch <INPUT name=ccard
type=radio value=Eurocard> Eurocard</TD></TR>
<TR>
<TD align=right class=greynormal>Credit card number:</TD>
<TD><INPUT maxLength=20 name=ccnumber> </TD>
<TD align=right class=greynormal>Expiration date:</TD>
<TD><INPUT maxLength=8 name=expdate size=8> </TD></TR>
<TR>
<TD align=right class=greynormal>Cardholders name:</TD>
<TD><INPUT name=textfield2 size=40> </TD>
<TD align=right class=greynormal>Card issuing bank:</TD>
<TD><INPUT maxLength=25 name=cardbank size=40> </TD></TR>
<TR>
<TD align=right class=greynormal vAlign=top>Cardholders address:<BR>(if
different from above)<BR></TD>
<TD><TEXTAREA cols=36 name=cardaddress rows=4 wrap=PHYSICAL></TEXTAREA>
</TD>
<TD align=right class=greynormal vAlign=top>Special orders or requests:</TD>
<TD><TEXTAREA cols=36 name=specialorder rows=4 wrap=PHYSICAL></TEXTAREA>
</TD></TR>
<TR>
<TD align=right class=greynormal>VAT number:</TD>
<TD><INPUT name=cardname size=40> </TD>
<TD align=right class=greynormal>Shipping destination:</TD>
<TD class=greysm><INPUT name=dest type=radio value=UK> UK <INPUT name=dest
type=radio value=EEC> EEC <INPUT name=dest type=radio value=USA> USA
<INPUT name=dest type=radio value=World> Rest of the World</TD></TR>
<TR>
<TD align=right>&nbsp;</TD>
<TD align=right><A
href="checkout.cfm"><IMG
border=0 height=26 name=Image24 src="checkout_files/reset.gif"
width=136></A> </TD>
<TD align=right vAlign=bottom>&nbsp; </TD>
<TD align=right><A
href="confirm.cfm"
target=mainFrame><IMG border=0 height=26 name=Image3
src="checkout_files/confirm.gif" width=136></A>
</TD></TR></TBODY></TABLE></FORM></BODY></HTML>
I am trying to do a calculation with Arrays. I have a shopping application created that displays the items that the user selects in a table this data comes from an array. The array is populated as the user goes through the site.
I ned to calculate each product by the amount and display it then add up the totals. The code for the page is given below.
The Price is where the quantity * the price will be displayed and the cost is all of the prices added up.
any ideas greatly appreciated.
Thanks
Anne
Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Checkout</TITLE>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type><LINK
href="checkout_files/styles.css" rel=stylesheet>
<META content="MSHTML 5.00.2919.6307" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff>
<!---<CFQUERY NAME="Basket_List" DATASOURCE="products">
SELECT id, description, category, pack_weight, price1, price2, price3, price4
FROM products
</CFQUERY>--->
<CFSET session.basket[ArrayLen(session.basket)][9]=form.quantity>
<FORM name="checkout" action="confirm.cfm" method=post>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0>
<TBODY>
<TR>
<TD bgColor=#999999 class=whitenormal height=20
width=210>&nbsp;&nbsp;Product Description</TD>
<TD align=middle bgColor=#cccccc class=whitenormal width=90>Code</TD>
<TD align=middle bgColor=#999999 class=whitenormal width=50>Category</TD>
<TD align=middle bgColor=#cccccc class=whitenormal width=40>Pack Weight</TD>
<TD align=middle bgColor=#999999 class=whitenormal width=60>Quantity</TD>
<TD align=middle bgColor=#cccccc class=whitenormal width=50>Unit(£)</TD>
<TD align=middle bgColor=#999999 class=whitenormal width=50></TD>
<TD align=middle bgColor=#cccccc class=whitenormal width=60>Cost (£)</TD>
<TD bgColor=#999999 class=whitenormal width=140>&nbsp;</TD></TR>
<TR>
<TD colSpan=9><IMG height=6 src="" width=1><IMG height=6
src="checkout_files/shim.gif" width=1><IMG height=10
src="checkout_files/shim.gif" width=1></TD></TR></TBODY></TABLE>
<CFLOOP index="rowCount" from="1" to="#ArrayLen(session.basket)#" step="1">
<CFOUTPUT>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0>
<TBODY>
<TR>
<TD bgColor=##cccccc class=whitenormal width=210><IMG align=left height=30
src="checkout_files/shim.gif" width=2>&nbsp;#session.basket[rowCount][2]#</TD>
<TD align=middle class=greysm width=90>#session.basket[rowCount][1]#</TD>
<TD align=middle class=greysm width=50>#session.basket[rowCount][3]#</TD>
<TD align=middle class=greysm width=40>#session.basket[rowCount][4]#</TD>
<TD align=middle class=greysm width=60>#session.basket[rowCount][9]#</TD>
<TD align=middle class=greysm width=50>Price</TD>
<TD align=middle class=greysm width=50>&nbsp;</TD>
<TD align=middle class=greysm width=60>Cost</TD>
<TD align=right width=70>
<A
href="detail.cfm"
target=mainFrame><IMG border=0 height=28 name=Image13
src="checkout_files/prod_update.gif" width=67></A> </TD>
<TD align=right width=70><A
href="checkout.cfm"?><IMG
border=0 height=28 name=Image2 src="checkout_files/remove.gif"
width=67></A></TD></TR>
<TR>
<TD colSpan=10><IMG height=5 src="checkout_files/shim.gif"
width=20></TD></TR></TBODY></TABLE>
</CFOUTPUT>
</CFLOOP>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width=750>
<TBODY>
<TR>
<TD bgColor=#cccccc height=20 width=450>&nbsp;</TD>
<TD bgColor=#cccccc class=coralnormal width=100>&nbsp;sub total</TD>
<TD align=middle bgColor=#999999 class=whitenormal width=60>1050.50</TD>
<TD bgColor=#cccccc width=140>&nbsp;</TD></TR>
<TR>
<TD height=5></TD>
<TD height=5></TD>
<TD></TD>
<TD></TD></TR>
<TR>
<TD align=middle class=coralmed height=45 rowSpan=3>Please
Note:<BR>clicking the 'CONFIRM ORDER' button below submits your order, so
if you need to make any changes to your order requirement, please do so
before clicking the button!</TD>
<TD bgColor=#cccccc class=purplenormal height=20>&nbsp;shipping</TD>
<TD align=middle bgColor=#999999 class=whitenormal>30.65</TD>
<TD bgColor=#cccccc>&nbsp;</TD></TR>
<TR>
<TD height=5></TD>
<TD></TD>
<TD></TD></TR>
<TR>
<TD bgColor=#cccccc class=purplenormal height=20>&nbsp;VAT</TD>
<TD align=middle bgColor=#999999 class=whitenormal>26.65</TD>
<TD bgColor=#cccccc>&nbsp;</TD></TR>
<TR>
<TD height=5></TD>
<TD height=5></TD>
<TD></TD>
<TD></TD></TR>
<TR>
<TD height=20>&nbsp;</TD>
<TD bgColor=#cccccc class=coralnormal height=20>&nbsp;Total</TD>
<TD align=middle bgColor=#999999 class=whitenormal height=3>1156.32</TD>
<TD bgColor=#cccccc height=3>&nbsp;</TD></TR></TBODY></TABLE>
<TABLE align=center border=0 cellPadding=2 cellSpacing=0 width=750>
<TBODY>
<TR>
<TD colSpan=4 height=5></TD></TR>
<TR>
<TD bgColor=#cccccc class=header colSpan=4>&nbsp;please enter/check your
details below.....</TD></TR>
<TR>
<TD class=greynormal height=5 width=120></TD>
<TD width=255></TD>
<TD class=greynormal width=120></TD>
<TD width=255></TD></TR>
<TR>
<TD align=right class=greynormal width=120>Name:</TD>
<TD width=255><INPUT name=name size=40> </TD>
<TD align=right class=greynormal width=120>Delivery address:</TD>
<TD rowSpan=3><TEXTAREA cols=36 name=address rows=4 wrap=PHYSICAL></TEXTAREA>
</TD></TR>
<TR>
<TD align=right class=greynormal>Home telephone:</TD>
<TD><INPUT maxLength=25 name=homephone size=25> </TD>
<TD>&nbsp;</TD></TR>
<TR>
<TD align=right class=greynormal>Work telephone:</TD>
<TD><INPUT maxLength=25 name=workphone size=25> </TD>
<TD>&nbsp;</TD></TR>
<TR>
<TD align=right class=greynormal>Fax:</TD>
<TD><INPUT maxLength=25 name=homefax size=25> </TD>
<TD align=right class=greynormal>Post code/Zip code:</TD>
<TD><INPUT maxLength=7 name=pcode size=7> </TD></TR>
<TR>
<TD align=right class=greynormal>Email address:</TD>
<TD><INPUT maxLength=50 name=email size=25> </TD>
<TD align=right class=greynormal>&nbsp;</TD>
<TD>&nbsp; </TD></TR>
<TR>
<TD align=right class=greynormal>Credit card:</TD>
<TD class=greynormal colSpan=3><INPUT CHECKED name=ccard type=radio
value=Mastercard> MasterCard <INPUT name=ccard type=radio value=Visa> Visa
<INPUT name=ccard type=radio value=Switch> Switch <INPUT name=ccard
type=radio value=Eurocard> Eurocard</TD></TR>
<TR>
<TD align=right class=greynormal>Credit card number:</TD>
<TD><INPUT maxLength=20 name=ccnumber> </TD>
<TD align=right class=greynormal>Expiration date:</TD>
<TD><INPUT maxLength=8 name=expdate size=8> </TD></TR>
<TR>
<TD align=right class=greynormal>Cardholders name:</TD>
<TD><INPUT name=textfield2 size=40> </TD>
<TD align=right class=greynormal>Card issuing bank:</TD>
<TD><INPUT maxLength=25 name=cardbank size=40> </TD></TR>
<TR>
<TD align=right class=greynormal vAlign=top>Cardholders address:<BR>(if
different from above)<BR></TD>
<TD><TEXTAREA cols=36 name=cardaddress rows=4 wrap=PHYSICAL></TEXTAREA>
</TD>
<TD align=right class=greynormal vAlign=top>Special orders or requests:</TD>
<TD><TEXTAREA cols=36 name=specialorder rows=4 wrap=PHYSICAL></TEXTAREA>
</TD></TR>
<TR>
<TD align=right class=greynormal>VAT number:</TD>
<TD><INPUT name=cardname size=40> </TD>
<TD align=right class=greynormal>Shipping destination:</TD>
<TD class=greysm><INPUT name=dest type=radio value=UK> UK <INPUT name=dest
type=radio value=EEC> EEC <INPUT name=dest type=radio value=USA> USA
<INPUT name=dest type=radio value=World> Rest of the World</TD></TR>
<TR>
<TD align=right>&nbsp;</TD>
<TD align=right><A
href="checkout.cfm"><IMG
border=0 height=26 name=Image24 src="checkout_files/reset.gif"
width=136></A> </TD>
<TD align=right vAlign=bottom>&nbsp; </TD>
<TD align=right><A
href="confirm.cfm"
target=mainFrame><IMG border=0 height=26 name=Image3
src="checkout_files/confirm.gif" width=136></A>
</TD></TR></TBODY></TABLE></FORM></BODY></HTML>