JS on checkbox Change enable or disable a radio button

Viewed 23

I have a check box that I want to enable these radio buttons. what I have does not work. how can I JS that?

im new. :(

var sipch = document.querySelector("input[name=sip]");
sipch.addEventListener( 'change', function() {
    if(sipch.checked) {
        document.getElementById("protocol").disabled=false;
    } else {
        document.getElementById("protocol").disabled=true;
    }
});
<input type="checkbox" name="sip" onsubmit="goPFive(event)" method="get">do this?
<input type="radio" class="testD" name="protocol" value="udp" disabled checked/>UDP
<input type="radio" class="testD" name="protocol" value="tcp" disabled />TCP
1 Answers

group your radio input with fieldset then set disabled attribute at fieldset element

<fieldset id="radioWrapper" disabled>
  <input type="radio" name="protocol" class="testD" value="udp"/>UDP
  <input type="radio" name="protocol" class="testD" value="tcp" />TCP
</fieldset>
Related