怎么样用JS隐藏下拉菜单里的值 5
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<table>
<tr>
<td><select name="TJYX" id="TJYX" size="1">
<option value="月平均" selected="selected" id="MAVG">月平均</option>
<option value="月最大值" id="MMAX" >月最大值</option>
<option value="月最小值" id="MMIN">月最小值</option>
<option value="月降雨量" id="MRL">月降雨量</option>
<option value="月降雨日数" id="MRD">月降雨日数</option>
<option value="月最大降雨量" id="MRMAX">月最大降雨量</option>
</select></td>
</tr>
</table>
</body>
</html>
在这里我在下拉菜单里只显示“月最大值”、“月最小值”,用javascript怎么控制啊? 展开
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<table>
<tr>
<td><select name="TJYX" id="TJYX" size="1">
<option value="月平均" selected="selected" id="MAVG">月平均</option>
<option value="月最大值" id="MMAX" >月最大值</option>
<option value="月最小值" id="MMIN">月最小值</option>
<option value="月降雨量" id="MRL">月降雨量</option>
<option value="月降雨日数" id="MRD">月降雨日数</option>
<option value="月最大降雨量" id="MRMAX">月最大降雨量</option>
</select></td>
</tr>
</table>
</body>
</html>
在这里我在下拉菜单里只显示“月最大值”、“月最小值”,用javascript怎么控制啊? 展开
1个回答
展开全部
我是用onload方法实现的 你可以把它改为按钮触发或是其他事件 下面是代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<SCRIPT LANGUAGE="JavaScript">
<!--
function delMonth(){
var sel=document.getElementById("TJYX");
var mavg=document.getElementById("MAVG");
var mrl=document.getElementById("MRL");
var mrd=document.getElementById("MRD");
var mrmax=document.getElementById("MRMAX");
sel.remove(mavg.index);
sel.remove(mrl.index);
sel.remove(mrd.index);
sel.remove(mrmax.index);
}
//-->
</SCRIPT>
</head>
<body onload="delMonth()">
<table>
<tr>
<td><select name="TJYX" id="TJYX" size="1">
<option value="月平均" selected="selected" id="MAVG">月平均</option>
<option value="月最大值" id="MMAX" >月最大值</option>
<option value="月最小值" id="MMIN">月最小值</option>
<option value="月降雨量" id="MRL">月降雨量</option>
<option value="月降雨日数" id="MRD">月降雨日数</option>
<option value="月最大降雨量" id="MRMAX">月最大降雨量</option>
</select></td>
</tr>
</table>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<SCRIPT LANGUAGE="JavaScript">
<!--
function delMonth(){
var sel=document.getElementById("TJYX");
var mavg=document.getElementById("MAVG");
var mrl=document.getElementById("MRL");
var mrd=document.getElementById("MRD");
var mrmax=document.getElementById("MRMAX");
sel.remove(mavg.index);
sel.remove(mrl.index);
sel.remove(mrd.index);
sel.remove(mrmax.index);
}
//-->
</SCRIPT>
</head>
<body onload="delMonth()">
<table>
<tr>
<td><select name="TJYX" id="TJYX" size="1">
<option value="月平均" selected="selected" id="MAVG">月平均</option>
<option value="月最大值" id="MMAX" >月最大值</option>
<option value="月最小值" id="MMIN">月最小值</option>
<option value="月降雨量" id="MRL">月降雨量</option>
<option value="月降雨日数" id="MRD">月降雨日数</option>
<option value="月最大降雨量" id="MRMAX">月最大降雨量</option>
</select></td>
</tr>
</table>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询