请教javascript省市联动,城市不出来?到底怎么了,高手快帮忙解决下,谢谢
<th>开户行省份</th><td><selectid="t_province"name="province"onchange="change(this.value)">...
<th>开户行省份 </th>
<td><select id="t_province" name="province" onchange="change(this.value)"><option value="1">北京市</option><option value="2">天津市</option><option value="3">河北省</option><option value="4">山西省</option><option value="5">内蒙古自治区</option </select></td>
</tr>
<tr>
<th>开户行城市 </th>
<td><select id="t_city" name="city"></select></td>
</tr>
<tr>
<th></th>
<td><input type="submit" value="提交" /></td>
</tr>
</table>
</form>
</div>
</div>
<script>
s=[['1001','1','北京市'],['1002','2','天津市'],['1003','3','石家庄市'],['1004','3','唐山市'],['1005','3','秦皇岛市'],['1006','3','邯郸市'],['1007','3','邢台市'],['1008','3','保定市'],['1009','3','张家口市'],['1010','3','承德市'],['1011','3','沧州市'],['1012','3','廊坊市'],['1013','3','衡水市'],['1014','4','太原市'],['1015','4','大同市'],['1016','4','阳泉市'],['1017','4','长治市'],['1018','4','晋城市'],['1019','4','朔州市'],['1020','4','晋中市'],['1021','4','运城市'],['1022','4','忻州市'],['1023','4','临汾市'],['1024','4','吕梁市'],['1025','5','呼和浩特市'],['1026','5','包头市'],['1027','5','乌海市'],['1028','5','赤峰市'],['1029','5','通辽市'],['1030','5','鄂尔多斯市'],['1031','5','呼伦贝尔市'],['1032','5','巴彦淖尔市'],['1033','5','乌兰察布市'],['1034','5','兴安盟'],['1035','5','锡林郭勒盟'],['1036','5','阿拉善盟' ],];
function change(id){
var e='';for(var i=0;i<s.length;i++){if(s[i][1]==id){e+='<option value="'+s[i][0]+'">'+s[i][2]+'</option>';}}
$('#t_city').html(e);
}
change1(1);
</script></div> </div>
</div>
<div style="clear:both"></div>
<div class="footer">
<div class="footer-main">
<ul>
</ul>
</div>
</div>
</body>
</html> 展开
<td><select id="t_province" name="province" onchange="change(this.value)"><option value="1">北京市</option><option value="2">天津市</option><option value="3">河北省</option><option value="4">山西省</option><option value="5">内蒙古自治区</option </select></td>
</tr>
<tr>
<th>开户行城市 </th>
<td><select id="t_city" name="city"></select></td>
</tr>
<tr>
<th></th>
<td><input type="submit" value="提交" /></td>
</tr>
</table>
</form>
</div>
</div>
<script>
s=[['1001','1','北京市'],['1002','2','天津市'],['1003','3','石家庄市'],['1004','3','唐山市'],['1005','3','秦皇岛市'],['1006','3','邯郸市'],['1007','3','邢台市'],['1008','3','保定市'],['1009','3','张家口市'],['1010','3','承德市'],['1011','3','沧州市'],['1012','3','廊坊市'],['1013','3','衡水市'],['1014','4','太原市'],['1015','4','大同市'],['1016','4','阳泉市'],['1017','4','长治市'],['1018','4','晋城市'],['1019','4','朔州市'],['1020','4','晋中市'],['1021','4','运城市'],['1022','4','忻州市'],['1023','4','临汾市'],['1024','4','吕梁市'],['1025','5','呼和浩特市'],['1026','5','包头市'],['1027','5','乌海市'],['1028','5','赤峰市'],['1029','5','通辽市'],['1030','5','鄂尔多斯市'],['1031','5','呼伦贝尔市'],['1032','5','巴彦淖尔市'],['1033','5','乌兰察布市'],['1034','5','兴安盟'],['1035','5','锡林郭勒盟'],['1036','5','阿拉善盟' ],];
function change(id){
var e='';for(var i=0;i<s.length;i++){if(s[i][1]==id){e+='<option value="'+s[i][0]+'">'+s[i][2]+'</option>';}}
$('#t_city').html(e);
}
change1(1);
</script></div> </div>
</div>
<div style="clear:both"></div>
<div class="footer">
<div class="footer-main">
<ul>
</ul>
</div>
</div>
</body>
</html> 展开
展开全部
<option value="5">内蒙古自治区</option </select>
改成
<option value="5">内蒙古自治区</option> </select>
更多追问追答
追问
不是那里,是下面javascript代码错了
追答
去掉change1(1);
<html>
<head><meta charset="utf-8"></head>
<th>开户行省份 </th>
<td>
<select id="t_province" name="province" onchange="change(this.value)">
<option value="1">北京市</option><option value="2">天津市</option>
<option value="3">河北省</option><option value="4">山西省</option>
<option value="5">内蒙古自治区</option >
</select></td>
</tr>
<tr>
<th>开户行城市 </th>
<td><select id="t_city" name="city"></select></td>
</tr>
<tr>
<th></th>
<td><input type="submit" value="提交" /></td>
</tr>
</table>
</form>
</div>
</div>
<script>
s=.....;//字数限制,自己加上
function change(id){
var e='';for(var i=0;i<s.length;i++){if(s[i][1]==id){e+='<option value="'+s[i][0]+'">'+s[i][2]+'</option>';}}
//$('#t_city').html(e);
document.getElementById("t_city").innerHTML=e;
}
</script></div> </div>
</div>
<div style="clear:both"></div>
<div class="footer">
<div class="footer-main">
<ul>
</ul>
</div>
</div>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询