建站常识

select 控制网页内容隐藏于显示的实现代码

发布时间 | 2017/1/10  点击 | 

<script> 
function setChange() 
{ 
if (document.f.selfs.value == "1") 
{ 
document.all.tb1.style.display = "block"; 
} 
else 
{ 
document.all.tb1.style.display = "none"; 
} 
if (document.f.selfs.value == "2") 
{ 
document.all.tb2.style.display = "block"; 
} 
else 
{ 
document.all.tb2.style.display = "none"; 
} 
} 
</script> 
<form name=f> 
<select name="selfs" size="1 onchange="setChange()"> 
<option selected>选择方式</option> 
<option value="1">方式1</option> 
<option value="2">方式2</option> 
</select> 
<table id='tb1' style='DISPLAY:none'>方式1</table> 
<table id='tb2' style='DISPLAY:none'>方式2</table> 
</form>

相关信息