Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] Force String to Float?


  • From: noah at onemorebug.com (Noah Sussman)
  • Subject: [Javascript] Force String to Float?
  • Date: Mon May 14 21:19:27 2007

On 5/14/07, tedd <tedd@xxxxxxxxxxxx> 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@xxxxxxxxxxxxxx

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