在FF浏览器下拉框清空的问题 document.form1.select_bmid.length = 0; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 document.form1.select_bmid.innerHTML = ""; 请查检你其它javascript语句是否准确。 最好在Netscape里调试,Netscape里有:tool-web development-javascript console可以很方便地查看错误。 我打源代码完整的贴出来了,大家看看,我这里运行还是有问题的。<html><head><title></title><meta content="text/html; charset=gb2312" http-equiv="Content-Type"><link rel="stylesheet" href="../template/style.css" type="text/css"><style type="text/css"><!--.STYLE3 {font-size: 9px}--></style></head><script language="JavaScript"><!--var subval = new Array();subval[0] = new Array('15','0','1-a')subval[1] = new Array('15','1','2-a')subval[2] = new Array('15','2','3-a')subval[3] = new Array('15','3','4-a')subval[4] = new Array('15','4','5-a')subval[5] = new Array('15','5','6-a')subval[6] = new Array('15','6','7-a')subval[7] = new Array('15','7','8-a')subval[8] = new Array('15','8','9-a')subval[9] = new Array('15','9','10-a')subval[10] = new Array('28','10','11-a')subval[11] = new Array('28','11','12-a')subval[12] = new Array('28','12','13-a')subval[13] = new Array('28','13','14-a')function changeselect1(locationid){ var bmtext; var bmid;// document.form1.select_bmid.options.length = 0;//按理来说这句应该是对的,可就是运行有问题 document.form1.select_bmid.innerHTML = "";//FF注意游览器提示这句有问题 for(i=0;i<subval.length;i++){ bmtext=subval[i][2]; bmid=subval[i][1]; var oOption = document.createElement('OPTION'); oOption.text = bmtext; oOption.value = bmid; if (subval[i][0] == locationid){ document.form1.select_bmid.options.add(oOption); } }}//--></script><body leftmargin="20" topmargin="20" marginwidth="20" marginheight="20" style="table-layout:fixed; word-break:break-all"><form action="" method="post" name="input" id="form1" ><select name="select_lmid" id="select_lmid" onChange="changeselect1(this.value)"><option value="" ></option><option value="15" >TEST</option><option value="28" >TEST2</option></select> <select name="select_bmid" id="select_bmid"></select></form></body></html> 谢谢大家的参于,这个问题我自己解决了,按标准的写法是:document.getElementById('form1').select_bmid.options.length = 0;按wasuka(曲奇的吹火棍) 的方法也可以,不过也不完全正确,正确的写法应该是document.getElementById('form1').select_bmid.innerHTML = ""; js选中问题 网页开发 js 正则分组问题?????????? Ext 中将后台id的值传给window组件中TabPanel怎么做? 【难题】iframe高度自适应问题 怎么修改对象的事件,例如:页面上有两个按钮,我想点击一个,修改另外一个按钮的单击事件! 从客户端取得远程服务器系统时间 "::","->"这两个符号有什么用途,意义 如何制作类似于marquee的效果 html文件引入另一个html头文件,造成js失效,请教 javascript里面的圆括号什么用 javaScript 的typeof 是做什么的,麻烦告诉我谢谢
可以很方便地查看错误。
<html>
<head>
<title></title>
<meta content="text/html; charset=gb2312" http-equiv="Content-Type">
<link rel="stylesheet" href="../template/style.css" type="text/css">
<style type="text/css">
<!--
.STYLE3 {font-size: 9px}
-->
</style>
</head>
<script language="JavaScript">
<!--
var subval = new Array();
subval[0] = new Array('15','0','1-a')
subval[1] = new Array('15','1','2-a')
subval[2] = new Array('15','2','3-a')
subval[3] = new Array('15','3','4-a')
subval[4] = new Array('15','4','5-a')
subval[5] = new Array('15','5','6-a')
subval[6] = new Array('15','6','7-a')
subval[7] = new Array('15','7','8-a')
subval[8] = new Array('15','8','9-a')
subval[9] = new Array('15','9','10-a')
subval[10] = new Array('28','10','11-a')
subval[11] = new Array('28','11','12-a')
subval[12] = new Array('28','12','13-a')
subval[13] = new Array('28','13','14-a')
function changeselect1(locationid)
{
var bmtext;
var bmid;
// document.form1.select_bmid.options.length = 0;//按理来说这句应该是对的,可就是运行有问题
document.form1.select_bmid.innerHTML = "";//FF注意游览器提示这句有问题
for(i=0;i<subval.length;i++){
bmtext=subval[i][2];
bmid=subval[i][1];
var oOption = document.createElement('OPTION');
oOption.text = bmtext;
oOption.value = bmid;
if (subval[i][0] == locationid){
document.form1.select_bmid.options.add(oOption);
}
}
}//-->
</script>
<body leftmargin="20" topmargin="20" marginwidth="20" marginheight="20" style="table-layout:fixed; word-break:break-all"><form action="" method="post" name="input" id="form1" >
<select name="select_lmid" id="select_lmid" onChange="changeselect1(this.value)">
<option value="" ></option>
<option value="15" >TEST</option>
<option value="28" >TEST2</option></select>
<select name="select_bmid" id="select_bmid"></select></form></body>
</html>
document.getElementById('form1').select_bmid.options.length = 0;
按wasuka(曲奇的吹火棍) 的方法也可以,不过也不完全正确,正确的写法应该是
document.getElementById('form1').select_bmid.innerHTML = "";