Answers for "onclick radio button"

55

radio buttons html

<input type="radio" name="gender" value="male"> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="other"> Other
Posted by: Guest on February-09-2020
8

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-->
Posted by: Guest on May-17-2020
0

onclick on radio button

Hi, I think all of the above might work. In case what you need is simple, I used:

<body>
    <div class="radio-buttons-choice" id="container-3-radio-buttons-choice">
        <input type="radio" name="one" id="one-variable-equations" onclick="checkRadio(name)"><label>Only one</label><br>
        <input type="radio" name="multiple" id="multiple-variable-equations" onclick="checkRadio(name)"><label>I have multiple</label>
    </div>

<script>
function checkRadio(name) {
    if(name == "one"){
    console.log("Choice: ", name);
        document.getElementById("one-variable-equations").checked = true;
        document.getElementById("multiple-variable-equations").checked = false;

    } else if (name == "multiple"){
        console.log("Choice: ", name);
        document.getElementById("multiple-variable-equations").checked = true;
        document.getElementById("one-variable-equations").checked = false;
    }
}
</script>
</body>
Posted by: Guest on February-04-2021

Code answers related to "onclick radio button"

Browse Popular Code Answers by Language