Thanks, Ben.  That clears the air.

Rick

-----Original Message-----
From: Ben Doom [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 27, 2002 12:18 PM
To: CF-Talk
Subject: RE: Best way to handle Checkboxes with Insert Query?


: I've read on this list that it's recommended to use #IsDefined()# in place
: of #ParameterExists()#,
: but doesn't IsDefined assume the existence of the variable, and therefore
: doesn't check
: for the existence as does ParameterExists?  CFPARAM? And why has
: ParameterExists become deprecated
: as a function anyway?

IsDefined() works very similarly to ParameterExists().  However, it's a bit
nicer in that IsDefined() takes a string rather than taking the variable
itself.  That means that I can, for example, build the variable name and
store it in another variable, then check it.  Okay, that wasn't very clear.
Therefore, an example is in order.

<cfset var = "record_" & dateformat(now(), "mmddyyyy")>
<cfif isdefined(var)>
.

is the same as
<cfif parameterexists(record_12272002)>

so with isDefined() you can look up dynamically generated variable names.

so,
isdefined("form.variable")
is equivalent to
parameterexists(form.variable)

: So...with that in mind, what's the best way to handle an Insert
: Query where
: checkboxes
: may or may not be checked on a form?

I just use a cfparam:
<cfparam name="checkboxfield" default="">
and now you just insert it.  If there's something else you want to be
inserted if the box(es) is (are) unchecked, just put that in the default
value.

HTH.



  --Ben Doom
    Programmer & General Lackey
    Moonbow Software


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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
Get the mailserver that powers this list at http://www.coolfusion.com

Reply via email to