Radio Button Redirect
Clear choices. This script parses a radio button group to find the selected value and uses it as the destination URL.
Choose your path:
Copy the Script
<script>
function goRadio() {
var radios = document.getElementsByName('site');
var url = "";
for (var i = 0; i < radios.length; i++) {
if (radios[i].checked) {
url = radios[i].value;
break;
}
}
if (url) window.location = url;
else alert("Please select an option.");
}
</script>
<input type="radio" name="site" value="page1.html"> Page 1<br>
<input type="radio" name="site" value="page2.html"> Page 2<br>
<button onclick="goRadio()">Go</button>
Frequently Asked Questions
Radio buttons are excellent when you want to force a single choice from a small list of mutually exclusive options (e.g., 'English' vs 'Spanish' or 'Free' vs 'Premium').
Yes. You can add `onclick="window.location=this.value"` directly to the radio input tag, removing the need for a submit button.
The script should check if any radio button is checked. If not, it displays an alert asking the user to make a selection.