I am trying to copy the value from the selected radio button to display in a text box. However, I can not get this to work. I have copied my code below.
Is anyone able to help me please?
function sync()
{
var n4 = document.getElementById('n4').checked;
var n1 = document.getElementById('n1');
n1.value = n4.value;
}
<form action="" id="n4" onkeyup="sync()">
<input type="radio" name="gender" value="male" id"4" onkeyup="sync()"> Male<br>
<input type="radio" name="gender" value="female" onkeyup="sync()"> Female<br>
<input type="radio" name="gender" value="other" onkeyup="sync()"> Other
</form>
<input type="text" name="n1" id="n1" >