Stephen I changed the code as you suggested but got errors and so went back to the original code :(

So if anyone can help sort his one out please I would be very grateful. (code follows) and see previous threads ...

I put the cfoutput in the code to see whats being evaluated and sure enough as expected its the Item Number. However when the size has no value (a null in the database) I get

Element FIELDNAMES is undefined in FORM

Is this because the form variable isn't being passed across when

<cfif GetCartItems.ItemsItemSize eq ""> is processed?

Regards - Pau

--------------------- THE FORM ----------------------------------

<FORM ACTION="changequants.cfm" METHOD="POST" name="currentcart">

                <!--- This variable will be used to accumulate the total cost --->
                <CFSET TotalCost = 0>

                <!--- Now display the data for the current item --->
                <CFOUTPUT QUERY="GetCartItems">
                        <TR>
                                <TD BGCOLOR="##FFff99">#PartNum#</TD>
                                <TD BGCOLOR="##FFff99">#ItemName#</TD>
                                <td BGCOLOR="##FFff99">
                                        <cfif GetCartItems.ItemsItemSize eq "">
                                        <cfset 
Form["SelectSize#Replace(ItemIDPK,"-","_","ALL")#"] = 'x'>
                                        N/A
                                        <cfelse>
                                        <select 
name="selectSize#Replace(ItemIDPK,"-","_","ALL")#">

<cfloop index = "ListElement" list = "
#ValueList(GetCartItems.ItemsItemSize)#">
<cfif #ListElement# eq GetCartItems.CartItemsItemSize> <!--- preselect it --->
<option value="#ListElement#" selected>#ListElement#</option>
<cfelse>
<option value="#ListElement#">#ListElement#</option>
</cfif>
</cfloop>
</select>
</cfif>
</td>
<td BGCOLOR="##FFff99">colour</td>
<td ALIGN="RIGHT" bgcolor="##FFFF99">#lscurrencyFormat(ItemCost)#</TD>
<td bgcolor="##FFFF99">
<input type="Text" name="Quantity#Replace(ItemIDPK,"-","_","ALL")#" value="#Quantity#" align="RIGHT" size="3">
</TD>
<TD BGCOLOR="##FFff99" ALIGN="RIGHT">
#lscurrencyFormat(ItemCost * Quantity)#
</TD>
</TR>
<!--- Add cost of current item(s) to total cost --->
<CFSET TotalCost = TotalCost + (GetCartItems.ItemCost * GetCartItems.Quantity)>
</CFOUTPUT>


<TR>
<TD COLSPAN="6" BGCOLOR="#FFff99" ALIGN="RIGHT">
<FONT FACE="Helvetica" SIZE="-1"><B>Total</B></FONT>
</TD>
<TD BGCOLOR="#FFff99" ALIGN="RIGHT">
<!--- Display the total cost --->
<CFOUTPUT>
#lscurrencyFormat(TotalCost)#</FONT>
</CFOUTPUT>
</TD>
</TR>
</TABLE>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=382>
<TR>
<TD><BR><INPUT TYPE="SUBMIT" VALUE="Change Quantities"></TD>
<TD ALIGN="RIGHT"><BR><INPUT TYPE="BUTTON" VALUE="Checkout" onClick="location.href = 'checkout.cfm'"></TD>
</TR>


                </FORM>


-------------------------------- THE ACTION ----------------------------------------------


<!--- Get Cart Item Count --->
<CFQUERY  name="CartItems" Datasource="#application.dsn#">
        SELECT ItemIDPK, Quantity, itemsize
        FROM tblCartItems
        WHERE CartIDPK = '#Cookie.CartID#'
</cfquery>

<!--- Return the cart to the state it was at when the
     template that called this template was generated --->

<CFLOOP query="CartItems">
<cfset thing = ListFindNoCase(Form.FIELDNAMES,"SelectSize"&Replace(ItemIDPK,"-","_","ALL"))>
<cfoutput>#thing#</cfoutput>
<!--- If the cached quantity changed... --->
<CFIF CartItems.Quantity NEQ Form["Quantity#Replace(ItemIDPK,"-","_","ALL")#"]
AND IsNumeric(Form["Quantity#Replace(ItemIDPK,"-","_","ALL")#"])
AND Form["Quantity#Replace(ItemIDPK,"-","_","ALL")#"] LTE 1000
OR CartItems.ItemSize NEQ Form["SelectSize#Replace(ItemIDPK,"-","_","ALL")#"]>
<!--- Store new Quantity in a temporary Variable --->
<CFSET NewQuantity = Form["Quantity#Replace(ItemIDPK,"-","_","ALL")#"]>
<CFSET NewSize = Form["SelectSize#Replace(ItemIDPK,"-","_","ALL")#"]>
<!--- Update Quantity in Cart --->
<CFQUERY name="ChangeQuantity" datasource="#application.dsn#">
UPDATE tblCartItems
SET Quantity = #Val(Variables.NewQuantity)#,
<cfif NewSize neq "">
itemsize = '#newsize#'
</cfif>
WHERE CartIDPK = '#Cookie.CartID#'
AND ItemIDPK = #CartItems.ItemIDPK#
</cfquery>
</cfif>
</CFLOOP>




--
These lists are syncronised with the CFDeveloper forum at 
http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by 
activepdf.com*
     *Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com*
          *Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com*

To unsubscribe, e-mail: [EMAIL PROTECTED]



Reply via email to