日期:2014-05-16  浏览次数:20338 次

js通过下拉菜单选择不同的div显示
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<SCRIPT LANGUAGE="JavaScript">
<!--
var vis = 'b';
function change(){
    vis=document.getElementById('PM').value;
var a = document.getElementById('a');
var b = document.getElementById('b');
if(vis=='b'){
a.style.display = 'block';
b.style.display = 'none';
vis = 'a';
}else{
a.style.display = 'none';
b.style.display = 'block';
vis = 'b';
}
}

//-->
</SCRIPT>
</HEAD>

<BODY>
<select id="PM" onchange="change()">
<option value="a">a</option>
<option value="b">b</option>
</select>
<div id = "a" style = "display:none">
<select id="a">
<option value="test1">a.test1</option>
<option value="test2">a.test2</option>
</select>
</div>

<div id = "b">
<select id="b">
<option value="sb">sb</option>
<option value="sb1">sb1</option>
</select>
</div>
</BODY>
</HTML>