1 Replies - 467 Views - Last Post: 29 May 2018 - 12:29 PM

#1 benjaminjenney   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-April 18

can not read property 'value' of null.

Posted 29 May 2018 - 12:28 PM

line four keeps throwing the error property 'value' of null. Can not figure out why.

<html>
    <title>Factorials</title>
<script type="text/javascript">
    const stream = parseFloat(document.getElementById('out').value);
    let x = 1
    function factorize () {
        for(i=1;i<=stream;i++){
         x = x * i;
        }
document.getElementById('output').innerHTML = x;    
}
 </script> 
<body>
    <h1>FACTORIALS!</h1>
    <input type='text' size=3 id = 'out' value = 10>
    <button type='button' onclick='factorize();'>factored</button> 
    <div id ='output'></div>
</body>
</html>



Is This A Good Question/Topic? 0
  • +

Replies To: can not read property 'value' of null.

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14501
  • View blog
  • Posts: 58,134
  • Joined: 12-June 08

Re: can not read property 'value' of null.

Posted 29 May 2018 - 12:29 PM

What happens when you put the JQUERY script AFTER the HTML rendering?
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1