Coldfusion isDefined function problem

Posted on 2011-10-14
Last Modified: 2012-05-12
I have form name 123.

When I submit the form I am using isDefined but it through the error

Parameter 1 of function IsDefined, which is now form.123, must be a syntactically valid variable name.

Here is how I am using it

if (isDefined("form.#ID#")) {

where ID will be 123
Question by:erikTsomik
    LVL 39

    Accepted Solution

    I think the problem is that the variable has to start with a letter, not a number:   form.X123

    The isDefined() statement looks correct.

    Another way to do it, without using isDefined() would be ...

    <cfif structKeyExists(form,ID)>

    But I think you still have to change the variable name..

    LVL 19

    Author Comment

    well it works once it is defined
    LVL 19

    Author Closing Comment

    Struct KeyExists works. Thank you
    LVL 39

    Expert Comment

    Glad it worked, but I do suggest changing the variable name so you don't run into more problems.

    I verified from the CF documentation that you need to start with a character, not a number

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
    Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now