Hello all, More help required please ...
I have a form with the following select
<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>
This select actions on changequants.cfm
<CFLOOP query="CartItems">
<!--- 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>
The problem is that when there is no size in the database (as not all products have a size) the field becomes undefined.
I have tried isdefined but this doesn't work and reading in the book its something to do with Array Variables. I confess to nicking this code from an example and I guess it transfers the variables in an array.
How can I check to make sure that if the formvariable is null I trap the error and do something.
I have used isdefined, NOT is defined, eq "" etc etc but the code always crashes with a variable not defined error.
I can send the full code if anyone needs it ...
Regards - Paul (So near yet so far)
-- 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]
