Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculation using Arrays 1

Status
Not open for further replies.

anastasia

Programmer
Dec 13, 2000
111
GB
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 &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML><HEAD><TITLE>Checkout</TITLE>
<META content=&quot;text/html; charset=windows-1252&quot; http-equiv=Content-Type><LINK
href=&quot;checkout_files/styles.css&quot; rel=stylesheet>
<META content=&quot;MSHTML 5.00.2919.6307&quot; name=GENERATOR></HEAD>
<BODY bgColor=#ffffff>

<!---<CFQUERY NAME=&quot;Basket_List&quot; DATASOURCE=&quot;products&quot;>
SELECT id, description, category, pack_weight, price1, price2, price3, price4
FROM products
</CFQUERY>--->

<CFSET session.basket[ArrayLen(session.basket)][9]=form.quantity>

<FORM name=&quot;checkout&quot; action=&quot;confirm.cfm&quot; method=post>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0>
<TBODY>
<TR>
<TD bgColor=#999999 class=whitenormal height=20
width=210>&amp;nbsp;&amp;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>&amp;nbsp;</TD></TR>
<TR>
<TD colSpan=9><IMG height=6 src=&quot;&quot; width=1><IMG height=6
src=&quot;checkout_files/shim.gif&quot; width=1><IMG height=10
src=&quot;checkout_files/shim.gif&quot; width=1></TD></TR></TBODY></TABLE>

<CFLOOP index=&quot;rowCount&quot; from=&quot;1&quot; to=&quot;#ArrayLen(session.basket)#&quot; step=&quot;1&quot;>
<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=&quot;checkout_files/shim.gif&quot; width=2>&amp;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>&amp;nbsp;</TD>
<TD align=middle class=greysm width=60>Cost</TD>
<TD align=right width=70>

<A
href=&quot;detail.cfm&quot;
target=mainFrame><IMG border=0 height=28 name=Image13
src=&quot;checkout_files/prod_update.gif&quot; width=67></A> </TD>
<TD align=right width=70><A
href=&quot;checkout.cfm&quot;?><IMG
border=0 height=28 name=Image2 src=&quot;checkout_files/remove.gif&quot;
width=67></A></TD></TR>
<TR>
<TD colSpan=10><IMG height=5 src=&quot;checkout_files/shim.gif&quot;
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>&amp;nbsp;</TD>
<TD bgColor=#cccccc class=coralnormal width=100>&amp;nbsp;sub total</TD>
<TD align=middle bgColor=#999999 class=whitenormal width=60>1050.50</TD>
<TD bgColor=#cccccc width=140>&amp;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>&amp;nbsp;shipping</TD>
<TD align=middle bgColor=#999999 class=whitenormal>30.65</TD>
<TD bgColor=#cccccc>&amp;nbsp;</TD></TR>
<TR>
<TD height=5></TD>
<TD></TD>
<TD></TD></TR>
<TR>
<TD bgColor=#cccccc class=purplenormal height=20>&amp;nbsp;VAT</TD>
<TD align=middle bgColor=#999999 class=whitenormal>26.65</TD>
<TD bgColor=#cccccc>&amp;nbsp;</TD></TR>
<TR>
<TD height=5></TD>
<TD height=5></TD>
<TD></TD>
<TD></TD></TR>
<TR>
<TD height=20>&amp;nbsp;</TD>
<TD bgColor=#cccccc class=coralnormal height=20>&amp;nbsp;Total</TD>
<TD align=middle bgColor=#999999 class=whitenormal height=3>1156.32</TD>
<TD bgColor=#cccccc height=3>&amp;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>&amp;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>&amp;nbsp;</TD></TR>
<TR>
<TD align=right class=greynormal>Work telephone:</TD>
<TD><INPUT maxLength=25 name=workphone size=25> </TD>
<TD>&amp;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>&amp;nbsp;</TD>
<TD>&amp;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>&amp;nbsp;</TD>
<TD align=right><A
href=&quot;checkout.cfm&quot;><IMG
border=0 height=26 name=Image24 src=&quot;checkout_files/reset.gif&quot;
width=136></A> </TD>
<TD align=right vAlign=bottom>&amp;nbsp; </TD>
<TD align=right><A
href=&quot;confirm.cfm&quot;
target=mainFrame><IMG border=0 height=26 name=Image3
src=&quot;checkout_files/confirm.gif&quot; width=136></A>
</TD></TR></TBODY></TABLE></FORM></BODY></HTML>




 
Hi Anastasia,

Could you be a little more specific about the problem? I'm not sure what you're really needing help with first. To do the calculations, you just need a simple loop to go through the array, multiple price * quantity, and then add this to the master cost. If you can be more specific, I can give you a better answer.

GJ
 
Hi, GunJack.

Thank you for your reply, I have since managed to calculate the cost by multiplying the price wih the quantity and so on this works fine with the following code that follows. I do however have a problem in adding up all costs to form the Sub Total. As cost is a variable which i assume loses it's value when the user selects another product and so on. I need some way of storing all of the costs value and then add these all up??

Here is the code so far working fine but no SubTotal at moment.

Thanks again for your reply

Anne. p.s I am finding this part quite difficult as I am new to Cold Fusion etc.
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML><HEAD><TITLE>Checkout</TITLE>
<META content=&quot;text/html; charset=windows-1252&quot; http-equiv=Content-Type><LINK
href=&quot;checkout_files/styles.css&quot; rel=stylesheet>
<META content=&quot;MSHTML 5.00.2919.6307&quot; name=GENERATOR></HEAD>
<BODY bgColor=#ffffff>


<CFSET session.basket[ArrayLen(session.basket)][9]=form.quantity>

<FORM name=&quot;checkout&quot; action=&quot;confirm.cfm&quot; method=post>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0>
<TBODY>
<TR>
<TD bgColor=#999999 class=whitenormal height=20
width=210>&amp;nbsp;&amp;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>&amp;nbsp;</TD></TR>
<TR>
<TD colSpan=9><IMG height=6 src=&quot;&quot; width=1><IMG height=6
src=&quot;checkout_files/shim.gif&quot; width=1><IMG height=10
src=&quot;checkout_files/shim.gif&quot; width=1></TD></TR></TBODY></TABLE>

<CFLOOP index=&quot;rowCount&quot; from=&quot;1&quot; to=&quot;#ArrayLen(session.basket)#&quot; step=&quot;1&quot;>
<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=&quot;checkout_files/shim.gif&quot; width=2>&amp;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>

<CFSET Quantity=#session.basket[rowCount][9]#>

<CFIF #session.basket[rowCount][9]# LT 1>
<CFSET Price=#session.basket[rowCount][5]#>
<CFSET Cost=Price*Quantity>

<TD align=middle class=greysm width=50>£#DecimalFormat#Price##</TD>
<TD align=middle class=greysm width=50>&amp;nbsp;</TD>
<TD align=middle class=greysm width=60>£#DecimalFormat#Cost##</TD>
<TD align=right width=70>
</CFIF>

<CFIF #session.basket[rowCount][9]# GTE 1 >
<CFSET Price=#session.basket[rowCount][6]#>
<CFSET Cost=Price*Quantity>

<TD align=middle class=greysm width=50>£#Price#</TD>
<TD align=middle class=greysm width=50>&amp;nbsp;</TD>
<TD align=middle class=greysm width=60>£#Cost#</TD>
<TD align=right width=70>
</CFIF>

<CFIF #session.basket[rowCount][9]# EQ 12 GT 12>
<CFSET Price=#session.basket[rowCount][7]#>
<CFSET Cost=Price*Quantity>

<TD align=middle class=greysm width=50>£#Price#</TD>
<TD align=middle class=greysm width=50>&amp;nbsp;</TD>
<TD align=middle class=greysm width=60>£#Cost#</TD>
<TD align=right width=70>
</CFIF>

<CFIF #session.basket[rowCount][9]# EQ 144 GT 144>
<CFSET Price=#session.basket[rowCount][8]#>
<CFSET Cost=Price*Quantity>


<TD align=middle class=greysm width=50>£#Price#</TD>
<TD align=middle class=greysm width=50>&amp;nbsp;</TD>
<TD align=middle class=greysm width=60>£#Cost#</TD>
<TD align=right width=70>

</CFIF>


<A
href=&quot;detail.cfm&quot;
target=mainFrame><IMG border=0 height=28 name=Image13
src=&quot;checkout_files/prod_update.gif&quot; width=67></A> </TD>
<TD align=right width=70><A
href=&quot;checkout.cfm&quot;?><IMG
border=0 height=28 name=Image2 src=&quot;checkout_files/remove.gif&quot;
width=67></A></TD></TR>
<TR>
<TD colSpan=10><IMG height=5 src=&quot;checkout_files/shim.gif&quot;
width=20></TD></TR></TBODY></TABLE>

</CFOUTPUT>
</CFLOOP>

<CFOUTPUT>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width=750>
<TBODY>
<TR>
<TD bgColor=##cccccc height=20 width=450>&amp;nbsp;</TD>
<TD bgColor=##cccccc class=coralnormal width=100>&amp;nbsp;sub total</TD>
<TD align=middle bgColor=##999999 class=whitenormal width=60>SubTotal</TD>
<TD bgColor=##cccccc width=140>&amp;nbsp;</TD></TR>
</CFOUTPUT>


<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>&amp;nbsp;shipping</TD>
<TD align=middle bgColor=#999999 class=whitenormal>30.65</TD>
<TD bgColor=#cccccc>&amp;nbsp;</TD></TR>
<TR>
<TD height=5></TD>
<TD></TD>
<TD></TD></TR>
<TR>
<TD bgColor=#cccccc class=purplenormal height=20>&amp;nbsp;VAT</TD>
<TD align=middle bgColor=#999999 class=whitenormal>26.65</TD>
<TD bgColor=#cccccc>&amp;nbsp;</TD></TR>
<TR>
<TD height=5></TD>
<TD height=5></TD>
<TD></TD>
<TD></TD></TR>
<TR>
<TD height=20>&amp;nbsp;</TD>
<TD bgColor=#cccccc class=coralnormal height=20>&amp;nbsp;Total</TD>
<TD align=middle bgColor=#999999 class=whitenormal height=3>1156.32</TD>
<TD bgColor=#cccccc height=3>&amp;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>&amp;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>&amp;nbsp;</TD></TR>
<TR>
<TD align=right class=greynormal>Work telephone:</TD>
<TD><INPUT maxLength=25 name=workphone size=25> </TD>
<TD>&amp;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>&amp;nbsp;</TD>
<TD>&amp;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>&amp;nbsp;</TD>
<TD align=right><A
href=&quot;checkout.cfm&quot;><IMG
border=0 height=26 name=Image24 src=&quot;checkout_files/reset.gif&quot;
width=136></A> </TD>
<TD align=right vAlign=bottom>&amp;nbsp; </TD>
<TD align=right><A
href=&quot;confirm.cfm&quot;
target=mainFrame><IMG border=0 height=26 name=Image3
src=&quot;checkout_files/confirm.gif&quot; width=136></A>
</TD></TR></TBODY></TABLE></FORM></BODY></HTML>

 
&quot;I need some way of storing all of the costs value and then add these all up??&quot; --> that is why variables are for, you know ? use some kind of global, such as session variables

&quot;... I am new to Cold Fusion etc.&quot; --> what is the &quot;etc&quot; ? sounds like it's a lot ;-)

and please do not post ALL the code of ALL the page as more than the half is useless for the understanding
 
Thank you again iza for your reply.

I have tried what you suggestd in several different ways. It would work OK if I was just working with one price but I am working with 4 different prices and they are within IF statements. The problem is that once a variable hold the cost this is then overwritten if another product is chossen and so on? As you can see from the code below. You'll be happy to know I have cut it down a little?

Thanks

Anne.

CFLOOP index=&quot;rowCount&quot; from=&quot;1&quot; to=&quot;#ArrayLen(session.basket)#&quot; step=&quot;1&quot;>
<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=&quot;checkout_files/shim.gif&quot; width=2>&amp;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>

<CFSET Quantity=#session.basket[rowCount][9]#>

<CFIF #session.basket[rowCount][9]# LT 1>
<CFSET Price=#session.basket[rowCount][5]#>
<CFSET Cost=Price*Quantity>

<TD align=middle class=greysm width=50>£#DecimalFormat#Price##</TD>
<TD align=middle class=greysm width=50>&amp;nbsp;</TD>
<TD align=middle class=greysm width=60>£#DecimalFormat#Cost##</TD>
<TD align=right width=70>
</CFIF>

<CFIF #session.basket[rowCount][9]# GTE 1 >
<CFSET Price=#session.basket[rowCount][6]#>
<CFSET Cost=Price*Quantity>

<TD align=middle class=greysm width=50>£#Price#</TD>
<TD align=middle class=greysm width=50>&amp;nbsp;</TD>
<TD align=middle class=greysm width=60>£#Cost#</TD>
<TD align=right width=70>
</CFIF>

<CFIF #session.basket[rowCount][9]# EQ 12 GT 12>
<CFSET Price=#session.basket[rowCount][7]#>
<CFSET Cost=Price*Quantity>

<TD align=middle class=greysm width=50>£#Price#</TD>
<TD align=middle class=greysm width=50>&amp;nbsp;</TD>
<TD align=middle class=greysm width=60>£#Cost#</TD>
<TD align=right width=70>
</CFIF>

<CFIF #session.basket[rowCount][9]# EQ 144 GT 144>
<CFSET Price=#session.basket[rowCount][8]#>
<CFSET Cost=Price*Quantity>


<TD align=middle class=greysm width=50>£#Price#</TD>
<TD align=middle class=greysm width=50>&amp;nbsp;</TD>
<TD align=middle class=greysm width=60>£#Cost#</TD>
<TD align=right width=70>

</CFIF>


<A
href=&quot;detail.cfm&quot;
target=mainFrame><IMG border=0 height=28 name=Image13
src=&quot;checkout_files/prod_update.gif&quot; width=67></A> </TD>
<TD align=right width=70><A
href=&quot;checkout.cfm&quot;?><IMG
border=0 height=28 name=Image2 src=&quot;checkout_files/remove.gif&quot;
width=67></A></TD></TR>
<TR>
<TD colSpan=10><IMG height=5 src=&quot;checkout_files/shim.gif&quot;
width=20></TD></TR></TBODY></TABLE>

</CFOUTPUT>
</CFLOOP>

 
<cfset session.totaltotal=session.totaltotal+cost>

don't forget to set session.totaltotal to 0 when the user logs in
 
iza thanks again for your reply above. I have implemented this code and it is working better than it was. However the adding up is not what is expected. When displaying the sub-total for the first item this is fine but when other products are selected and added to the Array. The sub-total does not calculate properly it is adding up something but it is always way over the actual amount that should be displayed.

Again thank you for your help.

 
you've got ALL the informtions up there
now it's up to you
you should ask yourself questions such as : what a i adding ? how ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top