Dave, you're a twit. ;) Will... that's messy. :)
<cfset variables.cart[ARGUMENTS.merchID] = StructNew()> <cfset variables.cart[ARGUMENTS.merchID].qty = ARGUMENTS.quantity> <cfset variables.cart[ARGUMENTS.merchID].price = ARGUMENTS.price> <cfset variables.cart[ARGUMENTS.merchID].subtotal = ARGUMENTS.price * ARGUMENTS.quantity> There... no more extraneous hashes and quotes. <cffunction name="GetCartTotal" access="public" returntype="numeric" output="true" hint="Show total of cart in dollars"> <cfset var cartTotal = 0> <cfloop collection="#VARIABLES.cart#" item="thismerchID"> <cfset cartTotal = cartTotal + thismerchID.subtotal> </cfloop> <cfreturn cartTotal /> </cffunction> There... see how neat that is? Tidy, readable, indented... and much easier to follow for anyone trying to see what it does. It also works, I think... though I haven't tested it. :) Laterz, J On 4/27/05, Will Tomlinson <[EMAIL PROTECTED]> wrote: > > I'm having brain lock again. > > I've built a function that should loop over a struct and give me a total > for the cart items. Could someone point me in the right direction? > > here's what the struct looks like: > > <cfset variables.cart["#ARGUMENTS.merchID#"] = StructNew()> > <cfset variables.cart["#ARGUMENTS.merchID#"]["qty"] = > #ARGUMENTS.quantity#> > <cfset variables.cart["#ARGUMENTS.merchID#"]["price"] = #ARGUMENTS.price#> > <cfset variables.cart["#ARGUMENTS.merchID#"]["subtotal"] = > ARGUMENTS.price# * #ARGUMENTS.quantity#> > > And here's the function I need to build to get a running total. > > <cffunction name="GetCartTotal" access="public" returntype="numeric" > output="true" hint="Show total of cart in dollars"> > <cfloop collection="#VARIABLES.cart#" item="thismerchID"> > <cfset carttotal = VARIABLES.cart["#thismerch#"]["subtotal"]??????> > > </cfloop> > </cffunction> > > Thanks, > Will > -- --------------- ------------------------------------- Buy SQLSurveyor! http://www.web-relevant.com/sqlsurveyor Never make your developers open Enterprise Manager again. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:204878 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

