[Javascript] Force String to Float?

Noah Sussman noah at onemorebug.com
Mon May 14 21:19:22 CDT 2007


On 5/14/07, tedd <tedd at sperling.com> wrote:
> var one = document.autoSumForm.a1.value;
> var two = document.autoSumForm.d1.value;
> document.autoSumForm.t1.value = one + two;
>
> the result is not what I expect. Instead of getting 2 + 3 = 5, I get
> 2 + 3 = 23.
>
> So, how do I force a string to a float?

document.autoSumForm.t1.value = one*1 + two*1;


-- 
Noah Sussman
Noah at OneMoreBug.com

"A basic principle of data processing teaches the folly of trying to
maintain independent files in synchonism"  -- Fred Brooks



More information about the Javascript mailing list