469,282 Members | 1,704 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

how to force type cast ?

a simple question... I have a case where I' dlike to add values as
numbers and they seem to get added as a string concatination. how do I
force the + to add the values as numbers?

this is in an <INPUT onchange="OrderForm.TotalCharge.value=this.value
+ 1;" >

a related question is that I have some other calculations to do in
addition to this one-liner, so I am assuming I should write a little
<SCRIPT> function and just make the onchange="MyReCalc();"

thanks,

d
Jul 20 '05 #1
2 30779

"dan baker" <bo*****@yahoo.com> wrote in message
news:13**************************@posting.google.c om...
a simple question... I have a case where I' dlike to add values as
numbers and they seem to get added as a string concatination. how do I
force the + to add the values as numbers?

this is in an <INPUT onchange="OrderForm.TotalCharge.value=this.value
+ 1;" > <snip>

<URL: http://jibbering.com/faq/#FAQ4_21 >

- and -

<URL: http://www.litotes.demon.co.uk/js_in...e_convert.html


Richard.
Jul 20 '05 #2
"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
a simple question... I have a case where I' dlike to add values as
numbers and they seem to get added as a string concatination. how do I
force the + to add the values as numbers?

this is in an <INPUT onchange="OrderForm.TotalCharge.value=this.value
+ 1;" >

<snip>
------------------------------


thanks... I figured that the INPUT was treating things as text
strings, but had not found the parseInt() and parseFloat() functions
before.

d
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by NotYetaNurd | last post: by
3 posts views Thread by mra | last post: by
12 posts views Thread by Jeremy Chapman | last post: by
7 posts views Thread by Martin Robins | last post: by
5 posts views Thread by Eric bouxirot | last post: by
14 posts views Thread by andreyvul | last post: by
3 posts views Thread by Julie | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.