Welcome visitor
* Login
* Register
It is currently March 21st, 2019, 11:46 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » JavaScript



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  String to Integer
PostPosted: February 11th, 2009, 10:05 pm 
User avatar

Posts: 112
Hi there,
Im doing like a shopping options on my website, and my problem is that when i try to add the prices it just print both numbers, without doing any math at all. Any idea of how to fix this? I have already tried setting the value without the "" but still doesnt work.

thanks


Top
 Profile  
 
  Re: String to Integer
PostPosted: February 11th, 2009, 10:11 pm 

Posts: 96
This is a little trick you can use to make the computer realize that what you are using is a number. Just do a little mathematic operation with your variable and that will 'convert' it to an int variable.
var str=document.getElementById(ID).value;
int = str*1;


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » JavaScript


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron