这里是我的代码:显示/隐藏下拉
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script type="text/javascript">
document.getElementById("radio1").onchange = function() {
if(this.checked == true) {
document.getElementById("list1").style.visibility = "hidden";
document.getElementById("list1").style.display = "none";
}
};
document.getElementById("radio2").onchange = function() {
if(this.checked == true) {
document.getElementById("list1").style.visibility = "visible";
document.getElementById("list1").style.display = "block";
}
};
</script>
</HEAD>
<BODY>
<form method = "post">
<br /><p id="first"><label>First Name:</label><input type="text" name="first" size="30" /></p>
<br /><p id="last"><label>Last Name:</label><input type="text" name="last" size="30" /></p>
<br /><p id="instructor"><label>Instructor:</label><select name="instructor">
<option value="instructor1">instructor1</option>
<option value="instructor2">instructor2</option></select></p>
<br /><p id="hospitalorientation"><label>Hospital Orientation:</label>
<div id='buttons'>
<label><input id="radio1" type="radio" name="hospital" /> Not Complete </label>
<label><input id="radio2" type="radio" name="hospital" /> Complete </label>
</div>
<div id="list1" style="display: none;">
<label>Month Complete:
<select>
<option>January</option>
<option>February</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
<option>July</option>
<option>August</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
</select>
</label>
</div>
</form>
</BODY>
</HTML>
我将有更多的像医院领域领域,所以我需要做的不止一个。我需要一个下拉菜单来显示何时选中某个单选按钮。但所有我在JavaScript尝试不起作用。我是新来的JavaScript。
仍然无法正常工作:/ – Emily