I am working on a form that gets placed inside of a system I have no control over. One stipulation of this system is that all of the Names and IDs must match.
This poses a problem with Radios since they have to have the same name in order to function, which in turn means they have to have the same ID.
Is there syntax that would allow me to access a specific radio button based on it's Value and ".disabled = true" it that way?
As these are the only 2 radios on the form I think maybe I can loop through the radio elements and use the counter variable to modify them.
Edit: I am dumb, both radios were getting disabled before submission preventing the system from saving the radio selection. So really all I need to do is disable the unchecked radio button after the verify button loses focus and the system should save the checked radio itself. I tried to use the elements loop and target the checked status to disable but it doesn't disable the unchecked radio it seems to clear them both.
Thanks and sorry,
document.getElementById("btnVerify").onmouseleave = function(){
var radios = document.getElementsByName('rbRadios');
for (var r =0; r< radios.length; r++){
//radios[r].disabled = true;
if(radios[r].checked = false){
radios[r].disabled = true;
}
}
}
function enableButton(){
document.getElementById("btnVerify").disabled=false;
}
<input type="radio" name="rbRadios" id="rbRadios" value="Yes" onchange="enableButton()"> <label id="rbRadios">Yes</label>
<input type="radio" name="rbRadios" id="rbRadios" value="No" onchange="enableButton()"> <label id="rbRadios">No</label>
<button type="button" disabled id="btnVerify">Verify</button>