<!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> <script language="javascript">
var shopid = new array();
shopid[0] = new array("1","江山信息")
shopid[1] = new array("2","测试店铺")
var shopclass = new array();
var countlength111 = 5;
shopclass[0] = new array("1","1","短信产品");
shopclass[1] = new array("2","1","声讯产品");
shopclass[2] = new array("3","1","电视广告");
shopclass[3] = new array("4","2","测试");
shopclass[4] = new array("5","2","测试");
function sss(locationid)
{
document.getElementById("c_id").length = 0;
var locationid=locationid;
var i;
alert(countlength111.toString());
for (i=0;i<countlength111; i++)
{ alert(shopclass[i][0]);
document.getElementById("c_id").options[i]=new Option(shopclass[i][0],shopclass[i][2]);
}
}
</script>
<table bgcolor="#ffffff" borderColor="#f0f0f0" Border="1" Cellspacing="0" Cellpadding="5" width="100%" align="Center" style="border-collapse: collapse">
<tr>
<td width="17%">选择商铺</td>
<td><select name="shopid" class="input" id="shopid" onChange="sss(this.value)">
<option value=1>江山信息</option><option value=2>测试店铺</option>
</select></td>
</tr>
<tr>
<td>产品分类</td>
<td><select name="c_id" class="input" id="c_id">
<option value=1>短信产品</option><option value=2>声讯产品</option><option value=3>电视广告</option>
</select></td>
</tr>
</table>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body> <script language="javascript">
var shopid = new array();
shopid[0] = new array("1","江山信息")
shopid[1] = new array("2","测试店铺")
var shopclass = new array();
var countlength111 = 5;
shopclass[0] = new array("1","1","短信产品");
shopclass[1] = new array("2","1","声讯产品");
shopclass[2] = new array("3","1","电视广告");
shopclass[3] = new array("4","2","测试");
shopclass[4] = new array("5","2","测试");
function sss(locationid)
{
document.getElementById("c_id").length = 0;
var locationid=locationid;
var i;
alert(countlength111.toString());
for (i=0;i<countlength111; i++)
{ alert(shopclass[i][0]);
document.getElementById("c_id").options[i]=new Option(shopclass[i][0],shopclass[i][2]);
}
}
</script>
<table bgcolor="#ffffff" borderColor="#f0f0f0" Border="1" Cellspacing="0" Cellpadding="5" width="100%" align="Center" style="border-collapse: collapse">
<tr>
<td width="17%">选择商铺</td>
<td><select name="shopid" class="input" id="shopid" onChange="sss(this.value)">
<option value=1>江山信息</option><option value=2>测试店铺</option>
</select></td>
</tr>
<tr>
<td>产品分类</td>
<td><select name="c_id" class="input" id="c_id">
<option value=1>短信产品</option><option value=2>声讯产品</option><option value=3>电视广告</option>
</select></td>
</tr>
</table>
</body>
</html>
解决方案 »
- 问大家一个Jquery的问题
- 求一正则表达式
- 如何判断ie中是否已经安装简体字库
- 高分求助,急,在线等!
- 怎么样屏蔽IE浏览器的工具栏?在第一次用浏览器打开页面的时候?
- 在js中有没有办法获取一个变量的名字啊?比如说:var _Flat_Theme = new Object(); 使用一个函数 fnGetVarName(_Flat_Theme) 就能够返回
- JavaScript 中的实列对象如何删除 ?
- jqgrid 异常TypeError: obj is undefined ret = obj[expr];
- 来个大神看看 按照书上打的代码,但是没有效果
- 萌新看JavaScript入门书籍return false 加载两次疑问
- javascript代码兼容浏览器问题!谢谢!
- 函数前面的"var z= "加和不加影响这么大呀?请大家帮看看,谢谢了
我这里就好使了
不过 二级的select 不是汉字 而是 1,2,3,4,5
document.getElementById("c_id").options[i]=new Option(shopclass[i][0],shopclass[i][2]);
改成
document.getElementById("c_id").options[i].value=shopclass[i][0];
document.getElementById("c_id").options[i].text=shopclass[i][2]; 试一下