Solved

lsnumberformat Question?

Posted on 2002-03-16
3
214 Views
Last Modified: 2013-12-24
Can someone help me in this code:

<cfoutput query="GetAllAnswers">
<cfif #GetTotalRespondees.TotalVotes# is not 0>
<cfset Percentage= lsnumberformat(((
#GetAllAnswers.Results#/
#GetTotalRespondees.TotalVotes#)*100),
"999.0")>
<cfelse>
<cfset Percentage= 0>
</cfif>

when i excute it, it gives me this error message "Cannot convert 49.0 to number.

Please, check the ColdFusion manual for the allowed conversions between data types"

Note 49 is the totall votes.
0
Comment
Question by:iqbalwali
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
cheekycj earned 50 total points
ID: 6874286
Perhaps it considers your data to be strings instead of numbers

Check it this way:
<cfoutput query="GetAllAnswers">
<cfif IsNumeric(GetTotalRespondees.TotalVotes) AND IsNumeric(GetAllAnswers.Results)
AND GetTotalRespondees.TotalVotes NEQ 0>
<cfset Percentage= lsnumberformat(((
GetAllAnswers.Results/
GetTotalRespondees.TotalVotes)*100),
"999.0")>
<cfelse>
  Numbers were either 0 or not numeric: #GetTotalRespondees.TotalVotes#,#GetAllAnswers.Results#<br>
<cfset Percentage= 0>
</cfif>
</cfoutput>
0
 

Author Comment

by:iqbalwali
ID: 6874986
Thanx budy!
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 6875916
No problem.  Glad I could help and Thanx for the "A".
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now