Copy link to clipboard
Copied
Has anyone encountered this error? i am dividing two values to get a percentage. It works except at some point I recieve this error:
Use isNumeric() to verify that all the variables involved contain numbers.
Copy link to clipboard
Copied
Yes, when one of the values in a mathematical operation is an empty string you will get this error. At some point in your code execution one of your values is ending up as an empty string.
Copy link to clipboard
Copied
I' tried the following replace function, <cfset txtDeptList = replace (txtDeptList, "''", "", "ALL")>, but I've not had any success. Do you have any suggestions on how to eliminate the error.
Copy link to clipboard
Copied
Use isNumeric() to verify that all the variables involved contain numbers.
Copy link to clipboard
Copied
Thank you, something i should have thought of. The error went away!
Copy link to clipboard
Copied
One way to validate that you truly have numbers for your variables is to use the ColdFusion IsValid() function, for example, if you want to work only with integer numbers, you can use the function in the following way:
<cfif IsValid("integer",variables.a) and IsValid("integer", variables.b)>
<cfset Result = variables.a + variables.b>
</cfif>
IsValid works with alot of different data types, including verifying proper emails and also verifying a range of numbers.
You can find more information about this useful function at the adobe livedocs at the following URL:
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_in-k_37.html
Most of the web programming languages, like ASP.NET and others, have such functions for validating data types.
Hope this helps.
Michael G. Workman
michael.g.workman@gmail.com
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more