展开全部
一:JS文件:
复制代码
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;
}
}
if(++v<s.length){change(v);}
}
}
var dsy = new Dsy();
dsy.add ("0",["一年级","二年级"]);
dsy.add("0_0",["一班","二班"]);
dsy.add("0_0_0",["数学","语文"]);
dsy.add("0_0_1",["数学","语文"]);
dsy.add("0_1",["一班","二班","三班"]);
dsy.add("0_1_0",["数学","语文","英语","美术"]);
dsy.add("0_1_1",["数学","语文","英语","美术"]);
dsy.add("0_1_2",["数学","语文","英语","美术"]);
var s=["province","city","county"];
var opt0 = ["年级","班组","科目"];
function setup(){
for(i=0;i<s.length-1;i++)
document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
change(0);
}
二:联动表单,html文件
复制代码
<script language="javascript" src="1.js"></script>
<form id="Form1" method="post" runat="server">
<Select id="province" runat="server" NAME="province"></Select>
<Select id="city" runat="server" NAME="city"></Select>
<Select id="county" runat="server" NAME="city"></Select>
</form>
<SCRIPT language="javascript">
setup()
</SCRIPT>
复制代码
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;
}
}
if(++v<s.length){change(v);}
}
}
var dsy = new Dsy();
dsy.add ("0",["一年级","二年级"]);
dsy.add("0_0",["一班","二班"]);
dsy.add("0_0_0",["数学","语文"]);
dsy.add("0_0_1",["数学","语文"]);
dsy.add("0_1",["一班","二班","三班"]);
dsy.add("0_1_0",["数学","语文","英语","美术"]);
dsy.add("0_1_1",["数学","语文","英语","美术"]);
dsy.add("0_1_2",["数学","语文","英语","美术"]);
var s=["province","city","county"];
var opt0 = ["年级","班组","科目"];
function setup(){
for(i=0;i<s.length-1;i++)
document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
change(0);
}
二:联动表单,html文件
复制代码
<script language="javascript" src="1.js"></script>
<form id="Form1" method="post" runat="server">
<Select id="province" runat="server" NAME="province"></Select>
<Select id="city" runat="server" NAME="city"></Select>
<Select id="county" runat="server" NAME="city"></Select>
</form>
<SCRIPT language="javascript">
setup()
</SCRIPT>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询