homepage Welcome to WebmasterWorld Guest from 54.198.46.115
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
number to string viceversa
Sayantandutta




msg:4378699
 3:39 pm on Oct 24, 2011 (gmt 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

 

penders




msg:4378712
 4:07 pm on Oct 24, 2011 (gmt 0)

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


There should not be quotes around your variable names.

Sayantandutta




msg:4379007
 4:39 am on Oct 25, 2011 (gmt 0)

thanks

Skier88




msg:4380284
 5:28 pm on Oct 27, 2011 (gmt 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;

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved