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.
Author by
user3722860
Updated on June 04, 2022Comments
-
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 almost 10 yearsWhen I change the id to "numbEnd", I get this error: ReferenceError: Can't find variable: numb7
-
Nisse Engström almost 10 years@user3722860: I don't think the scope of the variable
numb7
incalc()
extends to thecalcNumbA()
function. You need the fulldocument.getElementById(...)
reference.