zl程序教程

您现在的位置是:首页 >  其它

当前栏目

dropdownlist之间的互相联动实现(显示与隐藏)

实现 显示 之间 隐藏 联动 互相 DropDownList
2023-06-13 09:14:14 时间
复制代码代码如下:

<scriptlanguage="javascript"type="text/javascript">

varArrchange1=newArray();
varArrchange2=newArray();
varArrchange3=newArray();
functionhide(s_id,index)
{
varxxx=document.getElementById(s_id);
varoldOption=xxx.children(index);
varoldStr=oldOption.innerText;
varnewOption=document.createElement("<div"+oldOption.outerHTML.match(/(<\w*)([^>]*)(>)/)[2]+">");
newOption.innerText=oldStr;
newOption.swapNode(oldOption);
//alert(xxx.innerHTML);
}

functionshow(s_id,index)
{
varxxx=document.getElementById(s_id);
varoldOption=xxx.children(index);
if(oldOption.tagName=="DIV")
{
varoldStr=oldOption.innerText;
varnewOption=document.createElement("<option"+oldOption.outerHTML.match(/(<\w*)([^>]*)(>)/)[2]+">");
newOption.innerText=oldStr;
newOption.swapNode(oldOption);
}
//alert(xxx.innerHTML);
}



functiononchange1()
{
vars_index=document.getElementById("Ddl_question1").options[document.getElementById("Ddl_question1").selectedIndex].value;
s_index=parseInt(s_index);
if(s_index==0)
{
show("Ddl_question2",Arrchange1[0]);
show("Ddl_question3",Arrchange1[0]);
Arrchange1.pop();
}
else
{
Arrchange1.push(s_index);
if(Arrchange1.length>0)
{
show("Ddl_question2",Arrchange1[0]);
}
if(Arrchange1.length>0)
{
show("Ddl_question3",Arrchange1[0]);
}
hide("Ddl_question2",s_index);
hide("Ddl_question3",s_index);
}
}
functiononchange2()
{
vars_index=document.getElementById("Ddl_question2").options[document.getElementById("Ddl_question2").selectedIndex].value;
s_index=parseInt(s_index);
if(s_index==0)
{
show("Ddl_question1",Arrchange1[0]);
show("Ddl_question3",Arrchange3[0]);
Arrchange2.pop();
}
else
{
Arrchange2.push(s_index);
if(Arrchange2.length>0)
{
show("Ddl_question1",Arrchange2[0]);
}
if(Arrchange2.length>0)
{
show("Ddl_question3",Arrchange2[0]);
}
hide("Ddl_question1",s_index);
hide("Ddl_question3",s_index);
}
}
functiononchange3()
{
vars_index=document.getElementById("Ddl_question3").options[document.getElementById("Ddl_question3").selectedIndex].value;
s_index=parseInt(s_index);
if(s_index==0)
{
show("Ddl_question1",Arrchange3[0]);
show("Ddl_question2",Arrchange3[0]);
Arrchange3.pop();
}
else
{
Arrchange3.push(s_index);
if(Arrchange1.length>0)
{
show("Ddl_question1",Arrchange3[0]);
}
if(Arrchange2.length>0)
{
show("Ddl_question2",Arrchange3[0]);
}
hide("Ddl_question1",s_index);
hide("Ddl_question2",s_index);
}
}

functiona(){alert("fuck");}
</script>

<selectname="Ddl_question1"id="Ddl_question1"onchange="onchange1()">
<optionvalue="0">请选择密保信息</option>
<optionvalue="1">您母亲的姓名是?</option>
<optionvalue="2">您父亲的姓名是?</option>
<optionvalue="3">您配偶的姓名是?</option>
<optionvalue="4">您的出生地是?</option>
<optionvalue="5">您高中班主任的姓名是?</option>
<optionvalue="6">您初中班主任的姓名是?</option>
<optionvalue="7">您小学班主任的姓名是?</option>
<optionvalue="8">您小学校名是?</option>
<optionvalue="9">您的学号(或工号)是?</option>
<optionvalue="10">您父亲的生日是?</option>
<optionvalue="11">您母亲的生日是?</option>
<optionvalue="12">您配偶的生日是?</option>

</select>
<selectname="Ddl_question2"id="Ddl_question2"onchange="onchange2()">
<optionvalue="0">请选择密保信息</option>
<optionvalue="1">您母亲的姓名是?</option>
<optionvalue="2">您父亲的姓名是?</option>
<optionvalue="3">您配偶的姓名是?</option>
<optionvalue="4">您的出生地是?</option>
<optionvalue="5">您高中班主任的姓名是?</option>
<optionvalue="6">您初中班主任的姓名是?</option>
<optionvalue="7">您小学班主任的姓名是?</option>
<optionvalue="8">您小学校名是?</option>
<optionvalue="9">您的学号(或工号)是?</option>
<optionvalue="10">您父亲的生日是?</option>
<optionvalue="11">您母亲的生日是?</option>
<optionvalue="12">您配偶的生日是?</option>

</select>
<selectname="Ddl_question3"id="Ddl_question3"onchange="onchange3()">
<optionvalue="0">请选择密保信息</option>
<optionvalue="1">您母亲的姓名是?</option>
<optionvalue="2">您父亲的姓名是?</option>
<optionvalue="3">您配偶的姓名是?</option>
<optionvalue="4">您的出生地是?</option>
<optionvalue="5">您高中班主任的姓名是?</option>
<optionvalue="6">您初中班主任的姓名是?</option>
<optionvalue="7">您小学班主任的姓名是?</option>
<optionvalue="8">您小学校名是?</option>
<optionvalue="9">您的学号(或工号)是?</option>
<optionvalue="10">您父亲的生日是?</option>
<optionvalue="11">您母亲的生日是?</option>
<optionvalue="12">您配偶的生日是?</option>

</select>