Joshua, thank you for taking the time to answer this ... I tried following
your advice below, but ran into a problem ... got an error when I tried to
put my array in the function call, I get an error cause it's not a string
... let me show you what I've got going ...
On the content page, I have a series of check boxes for item deleltion that
look like this:
<input type="checkbox" name="remove" value=""
onClick="removeSubmit('#cart[ThisOrder].ITEM_ID#');">
This calls the following javascript:
<cfoutput>
<script language="JavaScript">
function removeSubmit(removeVar) {
var removeThis = removeVar
document.removeForm.action = "index.cfm";
document.removeForm.saction.value = "remove_cart";
document.removeForm.CFID.value = "#URL.CFID#";
document.removeForm.CFTOKEN.value = "#URL.CFTOKEN#";
document.removeForm.remove.value = removeVar;
document.removeForm.submit();
}
</script>
</cfoutput>
<form name="removeForm">
<input type="hidden" name="saction">
<input type="hidden" name="CFID">
<input type="hidden" name="CFTOKEN">
<input type="hidden" name="remove">
</form>
On the remove page, I'm trying to do this:
<CFSCRIPT>
function removeItem(remove){
var removeprice = 0;
var i = 1;
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;
}
}
return cart;
client.subtotal=client.subtotal-request.removeprice;
client.totalitems=client.totalitems-1;
}
</CFSCRIPT>
<cfwddx action="CFML2WDDX"
input="#cart#"
output="client.cartItems"
usetimezoneinfo="No">
The whole thing then passes back to the content page to which redisplays the
updated cart.
So, as I said, for loop doesn't seem to be executing.
I guess I'm having a hard time seeing how I'm going to pass the arguments to
the removeItem() function, when it is a javascript function (to make the
page submit to the remove template) that is actually in the checkbox.
H.
> -----Original Message-----
> From: Joshua Miller [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, February 13, 2003 8: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
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4