Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72358

Javascript - Numbers showing as NaN and object undefined

$
0
0

I am trying to make a comment generator for a program we use, and I am having an issue with numbers. I originally got object undefined after doing the math when I used the block of code below:

totalPages = toString(totalPages);
pagesLeft = toString(pagesLeft);
pph = toString(pph);
hour = toString(hour);
minute = toString(minute);
weekTG = toString(weekTG);

Then, I tried using the Number function when I got the values from the HTML inputs:

var totalPages = document.getElementById("totalPages");
var startPage = document.getElementById("startPage");
var endPage = document.getElementById("endPage");
totalPages = Number(totalPages);
startPage = Number(startPage);
endPage = Number(endPage);

When I used the above method, I got NaN. I also tried using parseFloat but that did not work out. Could I have some help? If you would like to look at my code further, you can look here in script.js. The output is currently in the console, just to clear up any future confusion.


Viewing all articles
Browse latest Browse all 72358

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>