<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Select Region</title></Head><Scripttype= "Text/javascript"> varregionlist=[]; regionlist["Hunan Province"]=["Changsha","Zhuzhou","Shaoyang"]; regionlist["Guangdong province"]=["Guangzhou","Shenzhen","Dongguan"]; OnLoad=function(){ varselectprovince=Document.queryselector ("#province");//This place uses for (Var i=0;i<region.length;i++) will be error, do not know why, trouble to know the Great God to guide ha for(varIinchregionlist) { varelement=Document.createelement ("OPTION"); Element.value=i; Element.innerhtml=i; Selectprovince.appendchild (Element); } } functionchangecity () {varselectprovince=Document.queryselector ("#province"); varselectcity=Document.queryselector ("#city"); Selectcity.innerhtml="<option> Please select city/region </option>"; for(varIinchRegionlist[selectprovince.value]) { varelement=Document.createelement ("OPTION"); Element.value=Regionlist[selectprovince.value][i]; Element.innerhtml=Regionlist[selectprovince.value][i]; Selectcity.appendchild (Element); } }</Script><Body><DivID= "Main"> <DLclass= "Register_row"> <DT>Location:</DT> <DD> <SelectID= "Province"OnChange= "changecity ()"style= "width:120px;"> <option>Please select province/city</option> </Select> </DD> <DD> <SelectID= "City"style= "width:130px;"> <option>Please select a city/region</option> </Select> </DD> </DL></Div></Body></HTML>
JS registration Form to achieve regional selection effect