|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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... |
|
#2
|
|||
|
|||
|
nevermind, got it
![]() |
|
#3
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > IsDefined() question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|