没有查询!当用户选择有一个婴儿或军事离开单选按钮弹出。我无法获取所选按钮的值并将带有 id="choice" 的 innerHTML 更改为该值。有人可以帮忙吗?
<html>
<head>
<script>
//this function deals with changing the event
function changeMessage(oElement) {
//have a baby
if (oElement.value == "100") {
document.getElementById("btn").style.display = "none";
document.getElementById("radio").style.display = "inline-block";
document.getElementById("rd1").innerHTML = "C-Section";
document.getElementById("rd2").innerHTML = "Regular Birth";
document.getElementById("rd1").value = "C-Section";
document.getElementById("rd2").value = "Regular Birth";
//military leave
} else if (oElement.value == "15") {
document.getElementById("btn").style.display = "none";
document.getElementById("radio").style.display = "inline-block";
document.getElementById("rd1").innerHTML = "Training";
document.getElementById("rd2").innerHTML = "Active Duty";
document.getElementById("rd1").value = "Training";
document.getElementById("rd2").value = "Active Duty";
//no value, the first, blanck value
} else if (oElement.value == "0") {
document.getElementById("btn").style.display = "none";
document.getElementById("radio").style.display = "none";
} else {
document.getElementById("btn").style.display = "inline-block";
document.getElementById("radio").style.display = "none";
}
return;
}
</script>
</head>
<body>
<div style="margin-left:250px;">
<select id="leave" onchange="changeMessage(this);">
<option value="0"></option>
<option value="5">Get Married</option>
<option value="100">Have a Baby</option>
<option value="90">Adopt a Child</option>
<option value="35">Retire</option>
<option value="15">Military Leave</option>
<option value="25">Medical Leave</option>
</select>
<button id="btn" style="display:none" onclick="getInfo()"type="button">Process</button>
</div>
<div id="radio" style="display:none">
<div id="rd1"></div><input type="radio" name="sex" value="" />
<div id="rd2"></div><input type="radio" name="sex" value=""/>
</div>
<div id="choice">Radio Choice</div>