0

I am transferring a project from Codepen to my computer. When I load it from my computer I get an error here:

var get=document.getElementById('workTime'); //get the value of the Wokrktime

var endPoint=((2*(parseInt(get.value)))/60)+1.5;

I get Uncaught TypeError: Cannot read property 'value' of null. The error is for the last line. Could anyone point me to the right direction?

Kostis
  • 99
  • 10
  • Either element doesn't exist at all, or you are looking for it before it exists. Provide a [mcve] that reproduces problem – charlietfl Dec 14 '17 at 19:16
  • Assuming it's on the page when you call it, `get` returns a DOM node, which doesn't have a `value`. But it does have a `innerHTML`. Maybe that's what you're looking for? Also, `get` is not a very good name for a variable. – jmargolisvt Dec 14 '17 at 19:18
  • Hmm..it works in my codepen project though: https://codepen.io/Ispaxan/pen/mqpWjM?editors=1011 – Kostis Dec 14 '17 at 19:19
  • 1
    codepen makes sure js executes after the html exists. If your js is in head then it executes before – charlietfl Dec 14 '17 at 19:23
  • Ah, I see. Yeah, input will have value, sorry. I think the first comment ^^ is worth looking into then. – jmargolisvt Dec 14 '17 at 19:24
  • I have put it at the end of the HTML document and it seems to work but the $( document ).ready() seems not to work for some reason. – Kostis Dec 14 '17 at 19:42

0 Answers0