Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

isDefined throws an error

Status
Not open for further replies.

mrsbean

Technical User
Jul 14, 2004
203
US
I am a CF newbie, but fairly well versed in other things like PHP. I tried to use isDefined to tell me whether or not a variable had been declared. If it had not yet been declared, I wanted to give it a value, otherwise, I wanted to use the value that was called by a link which led to the page.

It seems frustrating to me that I can't do this, so there must be some other way to think of it.

Code:
  	  <cfif isDefined("#imv#")>
	  <cfelse>
	<cfset #imv# = 0>
	</cfif>
	  <tr><td valign="top"><a href="index.cfm?template=ec_category_edit_1&form_cat_id=1&imv=1"><img src="images/arrow.gif" align="left" class="arrowcss" /></a></td>
	  <td valign="top">Image Map(?)&nbsp;</td>
	  <td>
	  <cfif #imv# EQ 1>
	  <textarea  name="imageMap" cols="50" rows="5" id="imageMap"></textarea>
		</cfif>
		</td></tr>

Thanks in advance for any assistance.

MrsBean
 
Remove the output signs:
Code:
<cfif isDefined("imv")>

You don't need output signs inside of a cf tag, so you can even remove them from your cfif and cfset statements.
Code:
<cfset imv = 0>

<cfif imv EQ 1>

By the way, what you're trying to do:
I tried to use isDefined to tell me whether or not a variable had been declared. If it had not yet been declared, I wanted to give it a value, otherwise, I wanted to use the value that was called by a link which led to the page.
would be much easier by using cfparam. The following cfparam tag could replace the entire <cfif><cfelse><cfif> block that your currently using.
Code:
<cfparam name="imv" default="0">

Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top