Sorry, typo ... The first line of the script should look like:
function removeItem(myarray,rem){
Joshua Miller
Head Programmer / IT Manager
Garrison Enterprises Inc.
www.garrisonenterprises.net
[EMAIL PROTECTED]
(704) 569-9044 ext. 254
************************************************************************
*************
Any views expressed in this message are those of the individual sender,
except where the sender states them to be the views of
Garrison Enterprises Inc.
This e-mail is intended only for the individual or entity to which it is
addressed and contains information that is private and confidential. If
you are not the intended recipient you are hereby notified that any
dissemination, distribution or copying is strictly prohibited. If you
have received this e-mail in error please delete it immediately and
advise us by return e-mail to [EMAIL PROTECTED]
************************************************************************
*************
-----Original Message-----
From: Joshua Miller [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 13, 2003 11:08 PM
To: CF-Talk
Subject: RE: another pair of eyes on this CFScript, please
1. VAR your counter variable (i) - just for good measure.
2. To use variables inside a function you have to either pass them in or
create them in the function. So most likely CART and URL.REMOVE aren't
available to the function. You'll need to pass them both to the function
to use them.
3. After you change the array, you'll need to pass it back out to the
template as its been updated and its length has been changed by
ArrayDeleteAt()
Try this:
<cfscript>
function removeItem(array,rem){
var i=1;
var removeprice = 0;
for(i=1; i lte arrayLen(myarray); i=i+1) {
if (myarray[i].ITEM_ID IS rem) {
removeprice=myarray[i].PRICE;
ArrayDeleteAt(myarray, i);
break;
}
}
return myarray;
}
</cfscript>
Call it with something like:
<cfscript>cart=removeItem(cart,url.remove);</cfscript>
That should allow you to pass in your array and removal item, remove the
item if necessary and then pass back out the updated array.
Joshua Miller
Head Programmer / IT Manager
Garrison Enterprises Inc.
www.garrisonenterprises.net [EMAIL PROTECTED]
(704) 569-9044 ext. 254
************************************************************************
*************
Any views expressed in this message are those of the individual sender,
except where the sender states them to be the views of
Garrison Enterprises Inc.
This e-mail is intended only for the individual or entity to which it is
addressed and contains information that is private and confidential. If
you are not the intended recipient you are hereby notified that any
dissemination, distribution or copying is strictly prohibited. If you
have received this e-mail in error please delete it immediately and
advise us by return e-mail to [EMAIL PROTECTED]
************************************************************************
*************
-----Original Message-----
From: "Owens [mailto:"Owens]
Sent: Thursday, February 13, 2003 10:35 PM
To: CF-Talk
Subject: another pair of eyes on this CFScript, please
Here it is:
function removeItem(){
var removeprice = 0;
for(i=1; i lte arrayLen(cart); i=i+1) {
if (cart[i].ITEM_ID IS url.remove) {
removeprice=cart[i].PRICE;
ArrayDeleteAt(cart, i);
break;
}
}
}
As near as I can tell, nothing inside the "for" loop is executing.
I've tried replacing arrayLen with a hard variable, I've tried GTE ...
but if take everything out and do a writeout(), nothing appears. If I
do the writeoutput outside of the for loop, then it works. I've checked
the size of the arrayLen just prior to the loop, and it reads the
expected value.
It's the strangest thing ... this was working. I don't believe I
changed anything. Then it stopped working.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Owens
Internet Operations Coordinator
InsideVC.com/Ventura County Star
[EMAIL PROTECTED]
AIM: GoCatGo1956 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4