Solved

Adding two numbes together

Posted on 2014-12-19
4
68 Views
Last Modified: 2014-12-19
Hi,


I am trying to add my numbers together but nothing is working my logic as always is off.  

specially around the holidays.  

So, I need your help please!!!


<cfoutput query="FiveYearPlan"> 
            <cfset CostPlan = #replace(FiveYearPlan.MajorUpgradeCost,"<","&lt;")#>
            <cfset variables.CostPlanFrom = 0>
			
	<cfif #CostPlan# neq ''>
				<cfswitch expression="#CostPlan#">
 				<cfcase value="&lt;$100K">
                    <cfset variables.CostPlanFrom = variables.CostPlanFrom + 0>
                    0
 				</cfcase>
 				<cfcase value="$100K to $500K">
                	<cfset variables.CostPlanFrom = variables.CostPlanFrom + 100>
                    100
 				</cfcase>
 				<cfcase value="$500K to $1M">
                	<cfset variables.CostPlanFrom = variables.CostPlanFrom + 500>
 					500
 				</cfcase>
 				<cfcase value="$1M to $5M">
                    <cfset variables.CostPlanFrom = variables.CostPlanFrom + 1000000>
 					1000000
 				</cfcase> 
                <cfcase value=">$5M">
                    <cfset variables.CostPlanFrom = variables.CostPlanFrom + 5000000>
 					5000000
 				</cfcase>
                </cfswitch> 
           <cfelse>
           &nbsp;
           </cfif>
</cfoutput>		


<!--- variables.CostPlanFrom is not adding up ---> 
<!--- What am I doing wrong? ---> 

<cfoutput>#variables.CostPlanFrom#</cfoutput>  

Open in new window

0
Comment
Question by:lulu50
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 40509529
lol,  especially around the holidays!

I'm thinking that some of your switch cases are not matching.
Let's find out which ones by using the defaultcase...

<cfoutput query="FiveYearPlan"> 
            <cfset CostPlan = replace(FiveYearPlan.MajorUpgradeCost,"<","&lt;")>
            <cfset variables.CostPlanFrom = 0>
			
          	<cfif #CostPlan# neq ''>
				<cfswitch expression="#CostPlan#">
 				<cfcase value="&lt;$100K">
                    <cfset variables.CostPlanFrom = variables.CostPlanFrom + 0>
                    0
 				</cfcase>
 				<cfcase value="$100K to $500K">
                	<cfset variables.CostPlanFrom = variables.CostPlanFrom + 100>
                    100
 				</cfcase>
 				<cfcase value="$500K to $1M">
                	<cfset variables.CostPlanFrom = variables.CostPlanFrom + 500>
 					500
 				</cfcase>
 				<cfcase value="$1M to $5M">
                    <cfset variables.CostPlanFrom = variables.CostPlanFrom + 1000000>
 					1000000
 				</cfcase> 
                <cfcase value=">$5M">
                    <cfset variables.CostPlanFrom = variables.CostPlanFrom + 5000000>
 					5000000
 				</cfcase>
				<cfdefaultcase>
				   Could not match [#costPlan#]
				</cfdefaultcase>
                </cfswitch> 
           <cfelse>
              Empty CostPlan
           </cfif>
		   <br>
</cfoutput>		

Open in new window


If your query FiveYearPlan has an ID for each of the values, it might be better to use the ID in the cfswitch for an easier match.
0
 

Author Comment

by:lulu50
ID: 40509631
gdemaria I agree!!!!

having this defaultcase thing helps a lot specially around the holidays.  

I found the issue and fixed it thank you again.
0
 

Author Closing Comment

by:lulu50
ID: 40509632
Thank you
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 40509665
ha, yes, I always like using defaultcase around the holidays to help spot little problems, like who did I forget to buy a present for! :)
0

Featured Post

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question