Using the DOM and radio buttons
Since they share a name, the values of a group of radio buttons can be collected in an array-like object using the method getElementsByName
.
For each entry, the value attribute can be accessed as the value
property of the node object, and the checked
property will be true for the button which has been checked.
Note:
Hints:
- undefined
1
2
window.onload = startFunction;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
<!DOCTYPE html>
<html lang="en">
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX