Skip to main content
Participant
May 19, 2008
Question

isDefined question

  • May 19, 2008
  • 4 replies
  • 431 views
Is there a way to use the isDefined function to detect a cf element instead of a form element? For example, I know the following line doesn't work, but it should give you an idea of what I'm trying to do.

<cfif (isdefined(#FAIL#) AND #FAIL# EQ 1)>Please try again...</cfif>
This topic has been closed for replies.

4 replies

Inspiring
May 20, 2008
> For usdp, when you say "fail is set on the referring page", unless you pass
> that to the page with isDefined, the isDefined function will always return
> false.

Just to clarify what Dan's saying: variables generally only live for the
life of the request they were created within (with the exception of
session-, application- and server-scoped variables). So a variable set
during the preceding request ("the referring page") will not exist on the
subsequent "page". Hence isDefined() returning false.

--
Adam
Inspiring
May 20, 2008
If you use isDefined exactly the way it's described in the cfml reference manual, it will work with any variable.

For usdp, when you say "fail is set on the referring page", unless you pass that to the page with isDefined, the isDefined function will always return false.
Inspiring
May 19, 2008
Oh, never mind, must be an integer since you are comparing it to one. In that case, this should work:

<cfif isdefined("FAIL") AND #FAIL# EQ 1>Please try again...</cfif>
usdpAuthor
Participant
May 19, 2008
Hmm, that still doesn't work..
"Fail" is set on the referring page as this: <cfset Fail=1>
Inspiring
May 19, 2008
What does #FAIL# evaluate to?