Why can’t I get the input from the input box?

Because you can’t get the input value but you can have it like this.

function changeP() {
var foodname;
  var input = document.getElementById("input").value;
    if (input === "abc") {
        foodname = "Hey Yo!";
    } else if (input === "def") {
        foodname = "!oY yeH";
    } else {
        foodname = "N/A";
    }
}

Leave a Comment