html radio button checked
<input type="radio" id="huey" name="drone" value="huey"
checked>
<!-- https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio-->
html radio button checked
<input type="radio" id="huey" name="drone" value="huey"
checked>
<!-- https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio-->
radio button html js
getElementById("radio_button").checked(); //returns boolean
radio button js
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Radio Buttons</title>
</head>
<body>
<form>
<input type="radio" name="choice" value="yes" id="choice-yes">
<label for="choice-yes">Yes</label>
<input type="radio" name="choice" value="no" id="choice-no">
<label for="choice-no">No</label>
<button id="btn">Show Selected Value</button>
</form>
<script>
const btn = document.querySelector('#btn');
// handle button click
btn.onclick = function () {
const rbs = document.querySelectorAll('input[name="choice"]');
let selectedValue;
for (const rb of rbs) {
if (rb.checked) {
selectedValue = rb.value;
break;
}
}
alert(selectedValue);
};
</script>
</body>
</html>Code language: HTML, XML (xml)
radio input value
<input type="radio" name="test" id="test" value="this is the value">
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us