> I am having some trouble with dynamically named checkboxes.
> 
> On a form I have some dynamically named form variables. like....
> 
> <Cfloop from = 1 to = #vLoopNUm# index="x">
>       ...
>       <input type="checkbox" name="chkRemove#x#" value="">
> </Cfloop>
> 
> I submit to....
> 
> <Cfloop from = 1 to = #vLoopNUm# index="x">
>       ...
>       <cfset vRemove = "chkRemove#x#">
> 
> All of these work except for the checkbox. The reason is 
> because checkboxes aren't submitted of they aren't checked. 
> So I would think that I should use some thing like this to 
> verify that the variable exists before setting the variable 
> to it's value.
> 
> <cfif #parameterExists(evaluate(vRemove))#>
>       <cfset vremove = "1">
> <cfelse
>       cfset vremove="0">
> <cfif>
> 
> but this doesn't work either.

You can fix your problem by putting this directly after your CFLOOP in your
action page:

<cfparam name="chkRemove#x#" default="0">

The reason that your ParameterExists test isn't working is that you're
checking for vRemove, which isn't your checkbox but rather a local variable
that you're trying to create within the CFLOOP in your action page, based on
the value of the variable from the checkbox. But, if the variable from the
checkbox doesn't exist, you'll get an error when you reference it.

Also, you might want to use IsDefined instead of ParameterExists, generally,
since ParameterExists has been deprecated for some time. To use IsDefined to
test for the existence of Form.foo, you'd use something like this:

<cfif IsDefined("Form.foo")>

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444
______________________________________________________________________
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
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to