Created
July 23, 2014 17:36
-
-
Save attebury/5f9ba4c6024c7f13384f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<label> | |
<input type="radio" name="days" value="15" checked /> 15 | |
</label> | |
<label> | |
<input type="radio" name="days" value="30"/> 30 | |
</label> | |
<label> | |
<input type="radio" name="days" value="45"/> 45 | |
</label> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getSelectedRadioButtonValue = function (radioName) { | |
var radioButtons, | |
radiosLength; | |
radioButtons = document.getElementsByName(radioName); | |
radiosLength = radioButtons.length; | |
for (var i = 0; i < radiosLength; i++) { | |
if (radioButtons[i].checked) { | |
return radioButtons[i].value; | |
} | |
} | |
}; | |
console.log(getSelectedRadioButtonValue('days')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment