Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 406
  • Last Modified:

Coldfusion isDefined function problem

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
0
erikTsomik
Asked:
erikTsomik
  • 2
  • 2
1 Solution
 
gdemariaCommented:
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..

0
 
erikTsomikSystem Architect, CF programmer Author Commented:
well it works once it is defined
0
 
erikTsomikSystem Architect, CF programmer Author Commented:
Struct KeyExists works. Thank you
0
 
gdemariaCommented:
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
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now