• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

isDefined question

New Here ,
May 19, 2008 May 19, 2008

Copy link to clipboard

Copied

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>
TOPICS
Advanced techniques

Views

341

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 19, 2008 May 19, 2008

Copy link to clipboard

Copied

What does #FAIL# evaluate to?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 19, 2008 May 19, 2008

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 19, 2008 May 19, 2008

Copy link to clipboard

Copied

Hmm, that still doesn't work..
"Fail" is set on the referring page as this: <cfset Fail=1>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 19, 2008 May 19, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 19, 2008 May 19, 2008

Copy link to clipboard

Copied

LATEST
> 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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation