RadioNodeList#value doesn't return the proper value
Reported by
zfri...@gmail.com,
Jul 30
|
|||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Steps to reproduce the problem:
1. HTML code includes three input radio buttons with the same name and different values wrapped inside of a fieldset element.
<fieldset>
<legend>title</legend>
<input type="radio" name="demo" value="this">
<input type="radio" name="demo" value="or">
<input type="radio" name="demo" value="that">
</fieldset>
2. Add an event listener to each radio. When clicked we use a selector to grab the fieldset and display fieldset.elements.demo.value in the console.
document.querySelectorAll("[name='demo']").forEach(item =>
item.addEventListener("click", function() {
console.log(document.querySelector("fieldset").elements.demo.value);
}));
What is the expected behavior?
The value according to all of the documentation should be the value of the first radio input that has been checked.
What went wrong?
It continuously returns the first radio value regardless of what is checked.
Did this work before? N/A
Chrome version: 67.0.3396.99 Channel: n/a
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version:
http://jsfiddle.net/qorkn5wd/23/
,
Jul 30
,
Jul 30
Sounds like a plan. I assumed incorrectly that I would be able to access a field set without wrapping it in a form tag. Truthfully I hope at some point in the future that selectors will be able to determine if a collection is full of radio inputs dynamically, and therefore return a value property that indicates the checked elements value or undefined. Until then I'll just code around it.
,
Jul 30
|
|||
►
Sign in to add a comment |
|||
Comment 1 by woxxom@gmail.com
, Jul 30