JavaScript Program to Display Selected Option Using RadioButtons

Write a JavaScript program to display selected option using radiobuttons.



Source Code
<html>
<head>
    <title>Use of radio button</title>
    <script>
        function display(SelOption) 
        {
            document.getElementById("info").innerHTML = "You selected: " + SelOption;
        }
    </script>
</head>
<body>
<form>
    Gender</br>
    <input type="radio" name="gender" value="Male" onchange="display(this.value)"/>Male</input>
    <input type="radio" name="gender" value="Female" onchange="display(this.value)"/>Female</input>
</form>
<p id="info"></p>
</body>
</html>
Output





"Coding Hub - Learn to code" app now available on Google Play Store