Sorry about that.
I have a form page that lets a customer custom configure a computer system
and then add it to the shopping cart. Upon the adding of the first computer
to the cart the form variables pass over just fine and everything is hunky
dory, and if they add another system, that is fine also. The problem comes
in when the user decides to update the quantity of units purchased. When
they hit the update button, which their is just one on the page 2 things can
happen depending if their is hidden fields on the page or not.
1 If there is hidden fields, I can update 1 system just fine and pass all
the variables to the structure. If I try 2 systems then I have a comma
delimeted list of variables that passes and that wont work
2. If there is not any hidden fields, I get an error that it cannot find a
variable that it is looking for.
This is view cart page that posts back to itself
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<CFIF ISDEFINED("FORM.ACTION")>
<CFIF TRIM(FORM.ACTION) EQ "Add To Cart">
<CF_EXAMPLECART
SYSMODELNUM="#form.sysModelNum#"
PRICE="#form.show_price_top#"
QTY="#attributes.qty#"
CSE="#form.cse#"
CPU="#form.cpu#"
RAM="#form.ram#"
HDD="#form.hdd#"
SEC_HDD="#form.sec_hdd#"
MTR="#form.mtr#"
CTR="#form.ctr#"
VID="#form.vid#"
SND="#form.snd#"
CDR="#form.cdr#"
DVD="#form.dvd#"
CRW="#form.crw#"
MODEM="#form.modem#"
STG="#form.stg#"
SPK="#form.spk#"
NIC="#form.nic#"
CLNG="#form.clng#"
OS="#form.os#"
WAR="#form.war#">
</CFIF>
</CFIF>
<CFIF isDefined("URL.UPDATE")>
<CF_EXAMPLECART
SYSMODELNUM="#form.sysModelNum#"
PRICE="#form.show_price_top#"
QTY="#form.qty#"
CSE="#form.cse#"
CPU="#form.cpu#"
RAM="#form.ram#"
HDD="#form.hdd#"
SEC_HDD="#form.sec_hdd#"
MTR="#form.mtr#"
CTR="#form.ctr#"
VID="#form.vid#"
SND="#form.snd#"
CDR="#TRIM(form.cdr)#"
DVD="#form.dvd#"
CRW="#form.crw#"
MODEM="#form.modem#"
STG="#form.stg#"
SPK="#form.spk#"
NIC="#form.nic#"
CLNG="#form.clng#"
OS="#form.os#"
WAR="#form.war#">
</CFIF>
<CFIF isDefined("URL.DELETE")>
<CFIF TRIM(URL.DELETE) EQ "Delete">
<CF_ACT_CART_DELETE
SYSMODELNUM = "#form.sysModelNum#">
</CFIF>
</CFIF>
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
if (document.images) {
<!---ON IMAGES//--->
image1on = new Image();
image1on.src = "/_images/addtocart_on.gif";
image2on = new Image();
image2on.src = "/_images/customize_on.gif";
image3on = new Image();
image3on.src = "/_images/purple_products_on.gif";
image4on = new Image();
image4on.src = "/_images/purple_info_on.gif";
image5on = new Image();
image5on.src = "/_images/purple_support_on.gif";
image6on = new Image();
image6on.src = "/_images/purple_home_on.gif";
image7on = new Image();
image7on.src = "/_images/update_cart_on.gif";
image8on = new Image();
image8on.src = "/_images/del_items_on.gif";
image9on = new Image();
image9on.src = "/_images/show_details_on.gif";
image10on = new Image();
image10on.src = "/_images/hide_details_on.gif";
image11on = new Image();
image11on.src = "/_images/keep_shopping_on.gif";
image12on = new Image();
image12on.src = "/_images/checkout_on.gif";
<!---OFF IMAGES//--->
image1off = new Image();
image1off.src = "/_images/addtocart_off.gif";
image2off = new Image();
image2off.src = "/_images/customize_off.gif";
image3off = new Image();
image3off.src = "/_images/purple_products_off.gif";
image4off = new Image();
image4off.src = "/_images/purple_info_off.gif";
image5off = new Image();
image5off.src = "/_images/purple_support_off.gif";
image6off = new Image();
image6off.src = "/_images/purple_home_off.gif";
image7off = new Image();
image7off.src = "/_images/update_cart_off.gif";
image8off = new Image();
image8off.src = "/_images/del_items_off.gif";
image9off = new Image();
image9off.src = "/_images/show_details_off.gif";
image10off = new Image();
image10off.src = "/_images/hide_details_off.gif";
image11off = new Image();
image11off.src = "/_images/keep_shopping_off.gif";
image12off = new Image();
image12off.src = "/_images/checkout_off.gif";
}
function changeImages() {
if (document.images) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src =
eval(changeImages.arguments[i+1] + ".src");
}
}
}
//-->
</SCRIPT>
<LINK REL="stylesheet" HREF="/_css/cart.css">
<TITLE>Carnivore Shopping Cart</TITLE>
<SCRIPT LANGUAGE="javascript">
function redirectAndSubmit(theForm,theURL){
theForm.action = (theURL);
theForm.submit();
return true();
}
</script>
</HEAD>
<BODY class="body" leftmargin="5" topmargin="5">
<CFOUTPUT>
<TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0" BORDER="0">
<TR>
<TD BACKGROUND="/_images/dark_purple_spacer.gif" COLSPAN="5"><A
HREF="/index.cfm?fuseaction=home&#client.urltoken#"><IMG NAME="carnivorepc"
SRC="/_images/carnivorepc.gif" BORDER="0"></A></TD>
</TR>
</TABLE>
<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%">
<TR>
<TD WIDTH="94"><A
HREF="/index.cfm?fuseaction=products&#client.urltoken#"
onmouseover="changeImages('image3','image3on')"
onmouseout="changeImages('image3','image3off')"><IMG NAME="image3"
SRC="/_images/purple_products_off.gif" BORDER="0"></A></TD>
<TD WIDTH="94"><A HREF="/index.cfm?fuseaction=info&#client.urltoken#"
onmouseover="changeImages('image4','image4on')"
onmouseout="changeImages('image4','image4off')"><IMG NAME="image4"
SRC="/_images/purple_info_off.gif" BORDER="0"></A></TD>
<TD WIDTH="94"><A HREF="/index.cfm?fuseaction=support&#client.urltoken#"
onmouseover="changeImages('image5','image5on')"
onmouseout="changeImages('image5','image5off')"><IMG NAME="image5"
SRC="/_images/purple_support_off.gif" BORDER="0"></A></TD>
<TD WIDTH="94"><A HREF="/index.cfm?fuseaction=home&#client.urltoken#"
onmouseover="changeImages('image6','image6on')"
onmouseout="changeImages('image6','image6off')"><IMG NAME="image6"
SRC="/_images/purple_home_off.gif" BORDER="0"></A></TD>
<TD WIDTH="100%" ALIGN="right" BACKGROUND="/_images/purple_spacer.gif"
height="23"> </TD>
</TR>
</TABLE>
<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%">
<TR>
<TD ALIGN="right" COLSPAN="5"><APPLET CODE="fader25.class" WIDTH=280
HEIGHT=19 CODEBASE="/_cls/">
<PARAM NAME="AppletHome"
VALUE="http://johannes-schellen.home.ml.org/fader.html">
<PARAM NAME="bgColor" VALUE="##FFFFFF">
<PARAM NAME="InlineData" VALUE="
size=10|
time=4000|
color=3|
fadein=4|
color=6|
fadeout=2|
pause=3000|
font=arial|
text=New Intel P4 running at 1.7 ghz storms the market|
text=Carnivore PC® recognized as a leader in the industry|
text=Carnivore PC® is pleased to offer 24/7 technical support|">
</APPLET>
</TD>
</TR>
</TABLE>
</CFOUTPUT>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<TABLE ALIGN="center" CELLPADDING="0" CELLSPACING="0" WIDTH="70%"
BORDER="0">
<TR>
<TD BACKGROUND="/_images/purple_spacer.gif" HEIGHT="24" CLASS="header"
width="31%">System Summary</TD>
<TD BACKGROUND="/_images/purple_spacer.gif" HEIGHT="24" CLASS="header"
width="13%">Unit Cost</TD>
<TD BACKGROUND="/_images/purple_spacer.gif" HEIGHT="24" CLASS="header"
width="13%">Quantity</TD>
<TD BACKGROUND="/_images/purple_spacer.gif" HEIGHT="24" CLASS="header"
width="13%">total</TD>
</TR>
</TABLE>
<CFLOOP COLLECTION="#session.cart#" ITEM="i">
<TABLE ALIGN="center" CELLPADDING="0" CELLSPACING="0" WIDTH="70%"
BORDER="0">
<CFOUTPUT>
<FORM METHOD="post"
ACTION="/index.cfm?fuseaction=showCart&#client.urltoken#" NAME="cart1">
<TR>
<TD class="header" width="31%">#session.cart[i]["sysModelNum"]#</TD>
<TD class="cart" valign="top"
width="13%">#dollarFormat(session.cart[i]["show_price_top"])#</TD>
<TD valign="top" width="13%"><INPUT TYPE="text" NAME="qty"
VALUE="#Trim(session.cart[i]["qty"])#" SIZE="2" class="cart"></TD>
<cfset total = session.cart[i]["qty"] * session.cart[i]["show_price_top"]>
<TD class="cart" valign="top" width="13%">#dollarFormat(total)#</TD>
</TR>
</TABLE>
<p> </p>
<!---/ Remark out the hidden fields for testing.
<INPUT TYPE="hidden" NAMe="sysModelNum"
VALUE="#session.cart[i]["sysModelNum"]#">
<INPUT TYPE="hidden" NAME="show_price_top"
VALUE="#session.cart[i]["show_price_top"]#">
<INPUT TYPE="hidden" NAME="cse" VALUE="#session.cart[i]["cse"]#">
<INPUT TYPE="hidden" NAME="cpu" VALUE="#session.cart[i]["cpu"]#">
<INPUT TYPE="hidden" NAME="ram" VALUE="#session.cart[i]["ram"]#">
<INPUT TYPE="hidden" NAME="hdd" VALUE="#session.cart[i]["hdd"]#">
<INPUT TYPE="hidden" NAME="sec_hdd" VALUE="#session.cart[i]["sec_hdd"]#">
<INPUT TYPE="hidden" NAME="mtr" VALUE="#session.cart[i]["mtr"]#">
<INPUT TYPE="hidden" NAME="ctr" VALUE="#session.cart[i]["ctr"]#">
<INPUT TYPE="hidden" NAME="vid" VALUE="#session.cart[i]["vid"]#">
<INPUT TYPE="hidden" NAME="snd" VALUE="#session.cart[i]["snd"]#">
<INPUT TYPE="hidden" NAME="cdr" VALUE="#session.cart[i]["cdr"]#">
<INPUT TYPE="hidden" NAME="dvd" VALUE="#session.cart[i]["dvd"]#">
<INPUT TYPE="hidden" NAME="crw" VALUE="#session.cart[i]["crw"]#">
<INPUT TYPE="hidden" NAME="modem" VALUE="#session.cart[i]["modem"]#">
<INPUT TYPE="hidden" NAME="stg" VALUE="#session.cart[i]["stg"]#">
<INPUT TYPE="hidden" NAME="spk" VALUE="#session.cart[i]["spk"]#">
<INPUT TYPE="hidden" NAME="nic" VALUE="#session.cart[i]["nic"]#">
<INPUT TYPE="hidden" NAME="clng" VALUE="#session.cart[i]["clng"]#">
<INPUT TYPE="hidden" NAME="os" VALUE="#session.cart[i]["os"]#">
<INPUT TYPE="hidden" NAME="war" VALUE="#session.cart[i]["war"]#">
/--->
</CFOUTPUT>
</CFLOOP>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<CFOUTPUT>
<TABLE ALIGN="center" CELLPADDING="0" CELLSPACING="0" BORDER="0"
WIDTH="70%">
<TR>
<TD WIDTH="94"><A
HREF="javascript:redirectAndSubmit(document.forms[0],'/index.cfm?fuseaction=
showCart&update=Update&#client.urltoken#')"
onmouseover="changeImages('image7','image7on')"
onmouseout="changeImages('image7','image7off')"><IMG NAME="image7"
SRC="/_images/update_cart_off.gif" BORDER="0"></A></TD>
<TD WIDTH="94"><A
HREF="javascript:redirectAndSubmit(document.forms[0],'/index.cfm?fuseaction=
showCart&delete=Delete&#client.urltoken#')"
onmouseover="changeImages('image8','image8on')"
onmouseout="changeImages('image8','image8off')"><IMG NAME="image8"
SRC="/_images/del_items_off.gif" BORDER="0"></A></TD>
<TD WIDTH="94"><A
HREF="javascript:redirectAndSubmit(document.forms[0],'/index.cfm?fuseaction=
showCart&show=Show Details&#client.urltoken#')"
onmouseover="changeImages('image9','image9on')"
onmouseout="changeImages('image9','image9off')"><IMG NAME="image9"
SRC="/_images/show_details_off.gif" BORDER="0"></A></TD>
<TD WIDTH="94"><A
HREF="javascript:redirectAndSubmit(document.forms[0],'/index.cfm?fuseaction=
showCart&hide=Hide Details&#client.urltoken#')"
onmouseover="changeImages('image10','image10on')"
onmouseout="changeImages('image10','image10off')"><IMG NAME="image10"
SRC="/_images/hide_details_off.gif" BORDER="0"></A></TD>
<TD WIDTH="94"><A HREF="/index.cfm?fuseaction=products&#client.urltoken#"
onmouseover="changeImages('image11','image11on')"
onmouseout="changeImages('image11','image11off')"><IMG NAME="image11"
SRC="/_images/keep_shopping_off.gif" BORDER="0"></A></TD>
<TD WIDTH="94"><A HREF="##"
onmouseover="changeImages('image12','image12on')"
onmouseout="changeImages('image12','image12off')"><IMG NAME="image12"
SRC="/_images/checkout_off.gif" BORDER="0"></A></TD>
<TD WIDTH="100%" ALIGN="right" BACKGROUND="/_images/purple_spacer.gif"
height="23"> </TD>
</TR>
</TABLE>
</CFOUTPUT>
</FORM>
</BODY>
</HTML>
This is the structure
<CFLOCK scope="SESSION" timeout="20" type="EXCLUSIVE">
<CFSCRIPT>
if (not(isDefined("session.cart"))){
session.cart = structNew();
}
/* This is if you want to add the new qty to the existin qty
* If you want to update the existing qty, you can drop the if else and
only code the else block
*/
if (structKeyExists(session.cart,attributes.sysModelNum)) {
/*if the model number is in the cart, update your cart item with the new
quantity*/
session.cart[attributes.sysModelNum].qty =
session.cart[attributes.sysModelNum].qty + attributes.qty;
}
else {
/*if the model number isn't in the cart, add a cart item*/
session.cart[attributes.sysModelNum] = StructNew();
/* start adding the item to the cart */
session.cart[attributes.sysModelNum]["sysModelNum"] =
attributes.sysModelNum;
session.cart[attributes.sysModelNum]["show_price_top"] =
attributes.show_price_top;
session.cart[attributes.sysModelNum]["qty"] = attributes.qty;
session.cart[attributes.sysModelNum]["cse"] = attributes.cse;
session.cart[attributes.sysModelNum]["cpu"] = attributes.cpu;
session.cart[attributes.sysModelNum]["ram"] = attributes.ram;
session.cart[attributes.sysModelNum]["hdd"] = attributes.hdd;
session.cart[attributes.sysModelNum]["sec_hdd"] = attributes.sec_hdd;
session.cart[attributes.sysModelNum]["mtr"] = attributes.mtr;
session.cart[attributes.sysModelNum]["ctr"] = attributes.ctr;
session.cart[attributes.sysModelNum]["vid"] = attributes.vid;
session.cart[attributes.sysModelNum]["snd"] = attributes.snd;
session.cart[attributes.sysModelNum]["cdr"] = attributes.cdr;
session.cart[attributes.sysModelNum]["dvd"] = attributes.dvd;
session.cart[attributes.sysModelNum]["crw"] = attributes.crw;
session.cart[attributes.sysModelNum]["modem"] = attributes.modem;
session.cart[attributes.sysModelNum]["stg"] = attributes.stg;
session.cart[attributes.sysModelNum]["spk"] = attributes.spk;
session.cart[attributes.sysModelNum]["nic"] = attributes.nic;
session.cart[attributes.sysModelNum]["clng"] = attributes.clng;
session.cart[attributes.sysModelNum]["os"] = attributes.os;
session.cart[attributes.sysModelNum]["war"] = attributes.war;
}
</CFSCRIPT>
</CFLOCK>
<CFOUTPUT>
<CFDUMP var = #session.cart#>
</CFOUTPUT>
Any help would be gratly appreciated
DB
----- Original Message -----
From: "Larry Juncker" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Friday, November 02, 2001 12:14 PM
Subject: RE: form question
> Can you expand just a little on what you currently have.
> You are just a little broad here.
>
> Larry Juncker
> Senior Cold Fusion Developer
> Heartland Communications Group, Inc.
> [EMAIL PROTECTED]
>
> -----Original Message-----
> From: Douglas L. Brown [mailto:[EMAIL PROTECTED]]
> Sent: Friday, November 02, 2001 1:57 PM
> To: CF-Talk
> Subject: form question
>
>
> Hi all ....
>
>
> I have a shopping cart page that posts to itself for updating a shopping
> cart. Since it posts back to itself I cannot use hidden fields to pass
> values or the structure will duplicate everything. Anybody have any
> Ideas on the subject?
>
>
>
> <CF_SIGNATURE
> NAME="Douglas L. Brown"
> EMAIL="[EMAIL PROTECTED]"
> PHONE="714.538.6611"
> WEB="http://www.carnivorepc.com">
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists