I am using the following
var loan = parseFloat(document.getElementById("loanamount"));
document.getElementById('numpay').textContent = loan.toString();
and my html is this:
<p>Number of Payments: <a id="numpay"> </a> </p>
I feel like this should be working but cannot seem to get anything other than NaN in my html, no matter how I configure it. I know I am a novice at javascript but could you please give me a tip?
Thanks!
You need
parseFloat(document.getElementById("loanamount").value)most probablyTIP: Instead of
parseFloat, just use+to convert from strings to numbers. So+document.getElementById("loanamount").valueshould also serve your purpose.