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 January 26th, 2005, 05:21 PM
krakrMann krakrMann is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 9 krakrMann User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 51 m 55 sec
Reputation Power: 0
IsDefined Problems...

Hello, Novice Proggrammer here. I have a problem with CF function IsDefined. Here is my code:

<cfif IsDefined(#URL.no#)>
<cfset no = #URL.no#></cfif>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<cfswitch expression="no">
<cfcase value="1">
You chose one.
</cfcase>
<cfcase value="2">
You chose two.
</cfcase>
<cfcase value="3">
You chose three.
</cfcase>
<cfdefaultcase>
<p><a href="no.cfm?no=1">1</a></p>
<p><a href="no.cfm?no=2">2</a> </p>
<p><a href="no.cfm?no=3">3</a></p>
<p><a href="no.cfm?no=4">4</a></p>
</cfdefaultcase>
</cfswitch>


The logic behind the code is that all of this code is in one file. The idea is that when you first go to the page, it will present 1, 2, 3, 4 links to click on. Then it will take you back to the same page and give you a specific response, based on the clicked link.

This is made in CFCASE statements. The promblem is this. When you first go to the page. URL.no will be undifined. It will err out. Element NO is undefined in URL. Ofcourse it isnt defined. Its supposed to go straight to defaultcase statement.

The logic is, if its defined then pass it on to another var that my application can use. I know that Im not doing this right. Ben Forta and his 50$ WACK book isnt much help either.

Could one of you guys tell me how to right this wrong. Or point me in the right direction on where I could read more about CFIF statements and this IsDefined function?

I have been playing with this language for almost two years and love it to death. Its little stupid errs like this that make me lose my faith in Macromedia.

Thanks in advanced with all your help!

Reply With Quote
  #2  
Old January 26th, 2005, 05:56 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,655 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 13 h 29 m 8 sec
Reputation Power: 53
I'll help here, but a couple of things first. To start with, when you are asking for help, please post the actual error message as the sticky for the CF forum states. Second, while I know it can be frustrating to deal with errors, know that in 99.9% of cases the problem is your fault, not Macromedia's. So saying things like "this makes me lose faith in Macromedia" indicates a rather arrogant point of view.

Now, isDefined takes a string, not a variable. Try this:

<cfif IsDefined('URL.no')>
<cfset no = URL.no>
<cfelse>
<cfset no = "">
</cfif>

Also, the switch expression is evaluated, so I think what you really mean is:

<cfswitch expression="#no#">

Or better yet, don't rely on this sort of indirect behavior (not setting anything and expecting the default case to run). Also, you don't need to copy the URL variable over to "no". You can just do something like this:

<cfparam name="url.no" default="">
<cfswitch expression="#url.no#">
<cfcase value="1">
You chose one.
</cfcase>
<cfcase value="2">
You chose two.
</cfcase>
<cfcase value="3">
You chose three.
</cfcase>
<cfcase value="">
<p><a href="no.cfm?no=1">1</a></p>
<p><a href="no.cfm?no=2">2</a> </p>
<p><a href="no.cfm?no=3">3</a></p>
<p><a href="no.cfm?no=4">4</a></p>
</cfcase>
</cfswitch>

Hope that helps.
__________________
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

Last edited by kiteless : January 26th, 2005 at 06:09 PM.

Reply With Quote
  #3  
Old January 27th, 2005, 08:58 PM
krakrMann krakrMann is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 9 krakrMann User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 51 m 55 sec
Reputation Power: 0
Thanks

Thank you for taking the time to reply to my thread and your code. Now do you happen to know where I may read more about the IsDefined function? Im looking for commentary or just plain theory. I seem to not apply this function correctly, when I use it.

Reply With Quote
  #4  
Old January 27th, 2005, 09:04 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,655 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 13 h 29 m 8 sec
Reputation Power: 53
There are stickies at the top of the CF forum with links to resources and documentation...they're supposed to be the first thing you read when you come to a new forum!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > IsDefined Problems...


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 2 hosted by Hostway