5 Replies Latest reply on May 19, 2008 11:39 PM by Newsgroup_User

    isDefined question

    usdp
      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>
        • 1. Re: isDefined question
          Magikaru
          What does #FAIL# evaluate to?
          • 2. Re: isDefined question
            Magikaru Level 1
            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>
            • 3. Re: isDefined question
              usdp Level 1
              Hmm, that still doesn't work..
              "Fail" is set on the referring page as this: <cfset Fail=1>
              • 4. Re: isDefined question
                Dan Bracuk Level 5
                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.
                • 5. Re: isDefined question
                  Level 7
                  > 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