Closed
Bug 283164
Opened 20 years ago
Closed 20 years ago
getAttribute("value") returns null for HTMLSelectElement
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
VERIFIED
INVALID
People
(Reporter: mva_led, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
on the onchange event for a select, the getAttribute("value") returns null, but
the value property does return the correct value.
See the steps for a sample.
Reproducible: Always
Steps to Reproduce:
<select id="id3" onchange="show();">
fuction show()
{
x = document.getElementById("id3");
alert(x.value);
alert(x.getAttribute("value"));
}
Actual Results:
alerts:
<the selected value>
null
Expected Results:
<the selected value>
<the selected value>
Comment 1•20 years ago
|
||
The "value" content attribute is indeed empty (in fact it isn't set at all), hence the "null" response. The "value" DOM attribute is returning a value because that's not the same as the content attribute -- see the DOM2 HTML spec: http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-6043025
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
I want just point you out to:
<input id="id1" name="cb" type="checkbox" checked onchange="myshow()">
<SCRIPT LANGUAGE="JavaScript">
function myshow()
{
x = document.getElementById("id1");
alert(x.value);
alert(x.getAttribute("value"));
}
</SCRIPT>
alert(x.value); - always return 'on' never 'off' or some thing else
alert(x.getAttribute("value")); - always null
Updated•14 years ago
|
Assignee: general → nobody
Status: RESOLVED → VERIFIED
OS: Windows XP → All
Hardware: x86 → All
| Assignee | ||
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•