标题:javascript的二级联动无法调用
只看楼主
jasonzzs
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2012-5-9
结帖率:0
 问题点数:0 回复次数:0 
javascript的二级联动无法调用
以下是二级联动代码,在<select id="s1" name="depa"><option></option></select>中无法调用,求高手指教!
<SCRIPT LANGUAGE="JavaScript">
<!--
function Dsy()
{
this.Items = {};
}
Dsy.prototype.add = function(id,iArray)
{
this.Items[id] = iArray;
}
Dsy.prototype.Exists = function(id)
{
if(typeof(this.Items[id]) == "undefined") return false;
return true;
}

function change(v){
var str="0";
for(i=0;i<v;i++){ str+=("_"+(document.getElementById(s[i]).selectedIndex-1));};
var ss=document.getElementById(s[v]);
with(ss){
length = 0;
options[0]=new Option(opt0[v],opt0[v]);
if(v && document.getElementById(s[v-1]).selectedIndex>0 || !v)
{
if(dsy.Exists(str)){
ar = dsy.Items[str];
for(i=0;i<ar.length;i++)options[length]=new Option(ar[i],ar[i]);
if(v)options[1].selected = true;
}
0
}
if(++v<s.length){change(v);}
}
}

var dsy = new Dsy();

dsy.add("0",["生产部","工程部","质量部","工艺部","机械部"]);
dsy.add("0_0,["盘机","线退","天车","空拉","清洗","仓库"]);
dsy.add("0_1",["机修","电修","公共设施"]);
dsy.add("0_2",["实验室1","实验室2","办公室"]);
dsy.add("0_3",["技术"]);
dsy.add("0_4",["模具房","机加工"]);

//-->
</SCRIPT>
<SCRIPT language = javascript>
<!--

var s=["s1","s2"];
var opt0 = ["请选择部门","请选择组别"];
function setup()
{
for(i=0;i<s.length-1;i++)
document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
change(0);
}
//-->
</SCRIPT>
<body onload="setup()">
调用:<select id="s1" name="depa"><option></option></select>
    <select id="s2" name="gong"><option></option></select>
搜索更多相关主题的帖子: undefined javascript function change return 
2013-07-30 15:06



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-418254-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.089791 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved