<script language="JavaScript" type="text/javascript">
var city=[
["city1","city2","city3","city4"],
["city5","city6","city7"],
["city8","city9","city10"],
];
function getCity(){
var sltProvince=document.form1.province;
var sltCity=document.form1.city;
var provinceCity=city[sltProvince.selectedIndex - 1];
sltCity.length=1;
for(var i=0;i<provinceCity.length;i++){
sltCity[i+1]=new Option(provinceCity[i],provinceCity[i]);
}
}
</script>
<FORM METHOD=POST ACTION="" name="form1">
<SELECT NAME="province" onChange="getCity()">
<OPTION VALUE="0">select province </OPTION>
<OPTION VALUE="province1">province 1 </OPTION>
<OPTION VALUE="province2">province2</OPTION>
<OPTION VALUE="province3">province3 </OPTION>
</SELECT>
<SELECT NAME="city">
<OPTION VALUE="0">select the city</OPTION>
</SELECT>
</FORM>
the above code is according to the province select its city. there are some lines i don't understand well. expect some one can explain it. thank you.
1, what's these lines do and meaning?
var provinceCity=city[sltProvince.selectedIndex - 1];
and
sltCity.length=1;
sltCity[i+1]=new Option(provinceCity[i],provinceCity[i]);