This will make them select one first by using a function on change. By giving them the same name only one at a time can be selected, this will let you return the correct value.
From Chris's comment Also == true
is redundant and can be removed, because checked is a boolean.
function check() {
if (document.getElementById("radio_myself").checked) {
alert(document.getElementById("radio_myself").value);
} else {
alert(document.getElementById("radio_selse").value);
}
}
addEventListener("change", ({target}) => { if(target.matches("input[type='radio']")){ check(); } })
<span><input id="radio_myself" name="radSelse" type="radio" value="Myself"/>Myself</span>
<span><input id="radio_selse" name="radSelse" type="radio" value="Someone"/>Someone Else</span>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…