二级联动select

<script type="text/javascript">
var where = new Array(9);
function comefrom(loca,locaaddress2) {
this.loca = loca;
this.locaaddress2 = locaaddress2;
}

where[0]= new comefrom("办公费用","办公用品|快递费|办公耗材|登记费"); 
where[1] = new comefrom("租赁费","上海办公室|海南办公室|宁波办公室|西安办公室|河南办公室");
where[2] = new comefrom("物业水电费","上海物业费|上海水电费|海南物业费|海南水电费|宁波物业费|宁波水电费|西安物业费|西安水电费|河南水电费|河南物业费");
where[3] = new comefrom("社会保险费","三金|公积金|综合保险");
where[4] = new comefrom("交通费","市内交通费");
where[5] = new comefrom("车辆使用费","汽油停车路桥|保养维修费|通行费");
where[6] = new comefrom("差旅费","海南|河南|山东|江苏|浙江|陕西|其他地区");
where[7] = new comefrom("通讯费","固话通讯费|移动通讯费");
where[8] = new comefrom("运输费用","物流费");
where[9] = new comefrom("交际应酬费","午餐费|晚餐费|礼品|其他");

function select() {
with(document.forms[0].categoryFirst) {
var loca2 = options[selectedIndex].value;
//alert("loca2="+loca2);
for(i = 0;i < where.length;i ++) {
if (where[i].loca == loca2) {
loca3 = (where[i].locaaddress2).split("|");
//alert("loca3.length="+loca3.length);
for(j = 0;j < loca3.length;j++) {
with(document.forms[0].categorySecond) {
length = loca3.length;
options[j].text = loca3[j];
options[j].value = loca3[j];
//var loca4=options[selectedIndex].value;
}
}
break;
}
}
}

}
function select2(){
//document.all.type.value=document.all.categoryFirst.value+">>"+document.all.categorySecond.value;

}
function init() {
selectId = 0;
with(document.forms[0].categoryFirst) {
length = where.length;
for(k=0;k<where.length;k++) {
options[k].text = where[k].loca;
options[k].value = where[k].loca;
}
}
with(document.forms[0].categorySecond) {
loca3 = (where[selectId].locaaddress2).split("|");
length = loca3.length;
selectId2 = 0;
for(l=0;l<length;l++) {
options[l].text = loca3[l];
options[l].value = loca3[l];
}
}
}
</script>

<body οnlοad="init()">
类别:
<select name="categoryFirst" onChange="select()"></select>
详细类别:
<select name="categorySecond" onChange="select2()"></select>
</body>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值