en anden måde
<!DOCTYPE html>
<html>
<body>
<form id="frm" action="">
<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
<input type="hidden" name="gender_text" id="gender_text">
</form>
<script>
var element = document.getElementById("frm");
element.addEventListener("change", myFunction);
function myFunction() {
var elm = document.getElementById("gender_text");
var val = document.querySelector('input[name="gender"]:checked').value;
var input_type = (val == "other")? "text" : "hidden";
elm.type=input_type;
}
</script>
</body>
</html>