Drop the quotes.
Cold Fusion uses type less variables and will convert strings to numbers
easily. You need to build in checks to ensure that the passed form
variables are indeed numeric before you do any math on them.
Russel
============================================================
Russel Madere, Jr. Senior Web Developer
ICQ: 5446158 http://www.TurboSquid.com
Some days you eat the bear; some days the bear eats you.
============================================================
> -----Original Message-----
> From: Steve Doran [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 18, 2001 07:36
> To: CF-Talk
> Subject: string to number
>
>
> I am trying to get a variable to work that would tell me how many rooms a
> person would need if they has X amount of people in their party.
>
> Here is the Code I am working with:
>
> <CFSET Grp=("form.adult + form.children")>
>
> <CFSET SmRmRq=0>
>
> <CFIF Grp LTE 4>
> <CFSET SmRmRq=1>
> <CFELSEIF (Grp GTE 5) and (Grp LTE 8)>
> <CFSET SmRmRq=2>
> <CFELSEIF (Grp GTE 9) and (Grp LTE 12)>
> <CFSET SmRmRq=3>
> <CFELSEIF (Grp GTE 13) and (Grp LTE 16)>
> <CFSET SmRmRq=4>
> <CFELSEIF (Grp GTE 17) and (Grp LTE 20)>
> <CFSET SmRmRq=5>
> <CFELSEIF (Grp GTE 21) and (Grp LTE 24)>
> <CFSET SmRmRq=6>
> <CFELSEIF (Grp GTE 25) and (Grp LTE 28)>
> <CFSET SmRmRq=7>
> <CFELSEIF Grp GTE 29>
> <CFSET SmRmRq=8>
> </CFIF>
>
> The problem I am having is when you output grp it gives you the total of
> form.adult + form.children. But when you use grp to set the variable
> SmRmRq it goes to a string "number + number" and will not accurately
> convert the variable.
>
> Is there a way to change the grp to a number? In Javascript It would be
> something like Var = (parseInt(form.adult) + parseInt(form.children))
>
> Thanks in advance for any assistance,
>
> Steve Doran :)
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists