Runic
Runic

Reputation: 35

Getting value from text input using document.getElementByID not working

I'm doing a simple project with javascript and it requires me to get a value out of an HTML text input with javascript. In the following code I've found that nothing after line 6 works and I have no idea why. This has been driving me crazy for like two hours and I'm kind of at my wits end. Please help!

function letsPlayAGame() {
  var answer = Math.floor(Math.random() * 100 + 1);

  var guess = document.getElementByID("theinput").value;

  if (Number.isInteger(guess) == false) {
    document.getElementByID("label").innerHTML =
      "Please enter a number between 1 and 100!";
  } else if (guess < 1 || guess > 100) {
    document.getElementByID("label").innerHTML =
      "Please enter a number between 1 and 100!";
  } else {
    alert("not this part");
  }
}

Upvotes: 1

Views: 81

Answers (1)

Axel
Axel

Reputation: 5111

It should be:

document.getElementById

instead of

document.getElementByID

as Javascript is case sensitive.

Upvotes: 3

Related Questions