IsDefined is "roughly analogous" of "IsNull" ... though technically a
variable which is "null" has been defined and has a value of "null" or no
value ... Whether or not a form field is defined on the following page
depends upon the type of form field and what value(s) are entered/selected.
Radio buttons and check boxes are not defined unless one or more elements
are checked on the form on the previous page. All other form elements are
defined on the following page.
Generally speaking I try to avoid using IsNull() as a logical operator if at
all possible by using <cfparam> to ensure that variables are defined and
default to empty string or 0 and then use len(myvariable),
yesnoformat(myvariable) or just plain <cfif myvariable> as logical operators
-- the reason for this generally is that validation almost never stops at
IsDefined(), and almost always goes on to include len() or isdate() or some
other form of validation to ensure that the variable is in a given format,
so using <cfparam> helps to avoid situations where you might be tempted to
write somthing hideous like
<a href="<cfif isdefined("myhrefpage") and
len(trim(myhrefpage))>#myhrefpage#<cfelse>somepage.cfm</cfif>?<cfif
isdefined("myvariable") and
isdate(myvariable)>myvariable=#myvariable#&</cfif><cfif
isdefined("myothervariable") and
len(trim(myothervariable))>myothervariable=#myothervariable#&</cfif><cfif
isdefined("mythirdvariable") and mythirdvariable neq
myfourthvariable>mythirdvariable=#mythirdvariable#</cfif>"><cfif
isdefined("myfifthvariable") and
len(trim(myfifthvariable))>#myfifthvariable#</cfelse>This is a
link.</cfif></a>
Which I unfortunately saw a lot of at my last "permanent" job.
Isaac
Certified Advanced ColdFusion 5 Developer
www.turnkey.to
954-776-0046
> is
> <cfif isDefined("MyVariable")>
> Yes i am defined
> </cfif>
> better/faster than or do the same thing as
> (if you know the variable is defined) also
> if you dont know the variable is defined.
> <cfif Len(#MyVariable#)>
> Yes i am defined
> </cfif>
> i guess my 2nd question, is this...Does the isDefined("")
> look for something that is of a value greater than 1 Len()
> or should/would an empty variable (a form field that hasnt
> had anything typed in it), pass the isDefined("")
> test?
> just wondering ;)
> ...tony
> tony weeg
> [EMAIL PROTECTED]
> www.revolutionwebdesign.com
> rEvOlUtIoN wEb DeSiGn
> 410.334.6331
> __________________________________________________________
> ____________
> 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
______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.
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