| Author |
converting string integer value to real integer value for looping
|
steve kelly
Greenhorn
Joined: Feb 15, 2012
Posts: 25
|
|
OK this should be simple but I am scratching my head on it. I have a string value of an number within an html page(works fine). I then want to convert it to an integer so I can iterate through a fixed number of fields(totalSize var).
Code snippit below. I get this NaN value (putting totalSize inside of an alert())when doing parseInt. I want to be able to iterate through "totalSize". How do I do that once I have the correct string representation of my integer? Is there something I need to call on the Nan value to do it or?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56178
|
|
|
parseInt() should work fine, even if there's trailing spaces in the string. What exactly does the string contain?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
steve kelly
Greenhorn
Joined: Feb 15, 2012
Posts: 25
|
|
Bear Bibeault wrote:parseInt() should work fine, even if there's trailing spaces in the string. What exactly does the string contain?
Never mind. Gah, I was passing in wrong value. I need coffee<grin>
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
When using parseInt, you really should use a radix.
Eric
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56178
|
|
steve kelly wrote:I need coffee<grin>
Ah yes, uncaffeinated coding -- it's a killer!
|
 |
 |
|
|
subject: converting string integer value to real integer value for looping
|
|
|