急!函数错误!
以前帖子的内容,可惜我找不到了。
function setFirst(S){
S.First.options[0].value="a";
S.First.options[0].text="a";
S.First.options[1].value="b";
S.First.options[1].text="b";
S.First.options[2].value="c";
S.First.options[2].text="c";
S.First.options[3].value="无";
S.First.options[3].text="**请选择省份**";
S.First.options[3].selected=true;
S.First.length=4;
}
请问这个函数那里有错啊?
输出的时候默认的select里没有东西。
-------------------------------------------------------------
原来的代码
<SCRIPT language=JavaScript>
function setFirst(S){
S.First.options[0].value="a";
S.First.options[0].text="a";
S.First.options[1].value="b";
S.First.options[1].text="b";
S.First.options[2].value="c";
S.First.options[2].text="c";
S.First.options[3].value="无";
S.First.options[3].text="**请选择省份**";
S.First.options[3].selected=true;
S.First.length=4;
}
function setsecond(D){
var valueFirst=D.First.options[D.First.selectedIndex].value;
if(valueFirst.indexOf("无")==0)
{
D.second.length=1;D.second.options[0].value="无";
D.second.options[0].text="**请选择城市**"
D.second.options[0].selected=true;
}
else if(valueFirst.indexOf("a")==0)
{
D.second.length=3;
D.second.options[0].value="abuse";
D.second.options[0].text="abuse";
D.second.options[1].value="abandon";
D.second.options[1].text="abandon";
D.second.options[2].value="acuse";
D.second.options[2].text="acuse";
}
else if(valueFirst.indexOf("b")==0)
{
D.second.length=3;
D.second.options[0].value="bee";
D.second.options[0].text="bee";
D.second.options[1].value="bad";
D.second.options[1].text="bad";
D.second.options[2].value="born";
D.second.options[2].text="born";
}
else if(valueFirst.indexOf("c")==0)
{
D.second.length=3;
D.second.options[0].value="city";
D.second.options[0].text="city";
D.second.options[1].value="capity";
D.second.options[1].text="capity";
D.second.options[2].value="car";
D.second.options[2].text="car";
}
}
</script>
<body onload=setFirst(document.select);setsecond(document.select)>
<Form name="select" method="POST" action="xxx.asp">
<center>
<Table>
<TR> <td>请选择:</td>
<TD ><SELECT onchange=setsecond(document.select) name=First size="1" ></SELECT> <SELECT name=second size="1" ></SELECT> </TD>
</TR>
</Table></center>
</Form>