ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 22nd, 2005, 02:10 PM
FALCONSEYE FALCONSEYE is offline
Permanently Banned
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 377 FALCONSEYE Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 Day 16 h 57 m 14 sec
Warnings Level: 15
Number of bans: 1
Reputation Power: 0
Question IsDefined() question

i have the following

<input type="image" name="delete" src="btn_delete_a.gif" onClick="return confirm('Are you sure to delete this spot?');">

on the action page, when i try to check and see if this image is clicked, i get nothing.
<cfif IsDefined('form.delete')>
defined
<cfelse>
undefined
</cfif>

moreover, when i <cfdump> the form values, i do not see this
'delete' under FORM.FieldNames.
what can i do to check if this image is clicked?
thanks for the help in advance...

Reply With Quote
  #2  
Old April 22nd, 2005, 02:16 PM
FALCONSEYE FALCONSEYE is offline
Permanently Banned
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 377 FALCONSEYE Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 Day 16 h 57 m 14 sec
Warnings Level: 15
Number of bans: 1
Reputation Power: 0
nevermind, got it

Reply With Quote
  #3  
Old April 22nd, 2005, 02:41 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,700 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 17 h 45 m 21 sec
Reputation Power: 53
It's becoming best practice to use structKeyExists() rather than isDefined() because isDefined() will look for a variable in the all of the scopes that CF automatically looks at when searching for a variable, in this order:

Arguments
Variables (local scope)
CGI
Cffile
URL
Form
Cookie
Client

This can lead to unexpected behavior if you forget to scope your variable. If you're on a form action page and you say "isDefined( 'delete' )", the function will return true even if delete doesn't exist in the form scope but it does in the client scope, for example. If you do use isDefined(), definitely scope your variable every time, even if it is the variables scope. The variables scope is where it gets particularly tricky, because you could do #isDefined( 'myLocalVar' )# and again, it would return true even if there was no local variable with that name but there was one in the cookie scope, for example.

Using structKeyExists( form, 'delete' ) looks for the specified key ONLY in the specified scope and never anywhere else. Also, structKeyExists() is faster than isDefined(). So the jist is, it's faster and there's less possibility of unexpected behavior.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > IsDefined() question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT