Welcome to WebmasterWorld Guest from 23.20.6.115

Forum Moderators: open

Message Too Old, No Replies

number to string viceversa

     
3:39 pm on Oct 24, 2011 (gmt 0)

New User

joined:Oct 24, 2011
posts: 3
votes: 0



var aaa= formName.subtotal.value;
var bbb = formName.Hour.value * formName.Rate.value;
formName.subtotal.value= parseFloat ('aaa') + parseFloat ('bbb');



Trying to print subtotal but getting error message as Nan
4:07 pm on Oct 24, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3123
votes: 0


... = parseFloat('aaa') + parseFloat('bbb');


There should not be quotes around your variable names.
4:39 am on Oct 25, 2011 (gmt 0)

New User

joined:Oct 24, 2011
posts: 3
votes: 0


thanks
5:28 pm on Oct 27, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:July 30, 2009
posts: 130
votes: 0


A more succinct method is to use implied conversion:

var aaa = formName.subtotal.value;
var bbb = formName.Hour.value * formName.Rate.value;
formName.subtotal.value = +aaa + bbb;