object HTMLInputElement error with .value

12,153

Perhaps it's an old MSIE compatibility feature where all id and name attributes are added to the global object. Try giving your variable (or id) a different name.

Share:
12,153
user3722860
Author by

user3722860

Updated on June 04, 2022

Comments

  • user3722860
    user3722860 almost 2 years

    I have a problem with returning "[object HTMLInputElement]", this is my code:
    HTML:
    <input type="text" id="numb7">
    JavaScript:
    var numb7 = document.getElementById("numb7").value;

    When I alert numb7 it returns:
    [object HTMLInputElement]

    Can anyone help me?

    For the full code: Full Code

  • user3722860
    user3722860 almost 10 years
    When I change the id to "numbEnd", I get this error: ReferenceError: Can't find variable: numb7
  • Nisse Engström
    Nisse Engström almost 10 years
    @user3722860: I don't think the scope of the variable numb7 in calc() extends to the calcNumbA() function. You need the full document.getElementById(...) reference.