表格里三级联动取第三个下拉框值的问题
做了个插入资料的页面,在选择籍贯时通过三级联动来选择,联动做的对着,能看到选的值,但是选的值无法赋给单元格,省(陕西)-->市(西安)-->区(未央),需要把“未央区”赋值给“籍贯”这个字段,数据库表是YHSJ中的JG,问题是执行以下代码后,籍贯返回的是数字“1”,应该是这句“city[1]= new Array("未央区","1","1");”中的“1”,要返回字符“未央区”而不是数值“1”怎么改??
程序代码如下:
程序代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.> <html xmlns="http://www.> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>资料录入页面</title> <script language="JavaScript"> function bb(num){ city = new Array(); city[1]= new Array("西安","1","1"); city[2]= new Array("咸阳","2","1"); city[3]= new Array("宝鸡","3","1"); city[4]= new Array("洛阳","4","2"); city[5]= new Array("郑州","5","2"); city[6]= new Array("开封","6","2"); city[7]= new Array("成都","7","3"); city[8]= new Array("绵阳","8","3"); city[9]= new Array("广元","9","3"); //把数组的值用数据库读出 document.form1.s1.length = 0; document.form1.s2.length = 0; document.form1.s2.options[0]= new Option("还没有市","0"); document.form1.s1.options[0]= new Option("请选择市","0"); j=1; for(i=1;i<=9;i++) { if(city[i][2]==num) {document.form1.s1.options[document.form1.s1.length]= new Option(city[i][0],city[i][1]);} j++} } function cc(num){ city = new Array(); city[1]= new Array("未央区","1","1"); city[2]= new Array("雁塔区","2","1"); city[3]= new Array("灞桥区","3","1"); city[4]= new Array("秦都区","4","2"); city[5]= new Array("渭城区","5","2"); city[6]= new Array("渭滨区","6","3"); city[7]= new Array("金台区","7","3"); city[8]= new Array("陈仓区","8","3"); city[9]= new Array("老城区","9","4"); city[10]= new Array("涧西区","10","4"); city[11]= new Array("西工区","11","4"); city[12]= new Array("中原区","12","5"); city[13]= new Array("惠济区","13","5"); city[14]= new Array("金水区","14","5"); city[15]= new Array("龙亭区","15","6"); city[16]= new Array("金明区","16","6"); city[17]= new Array("鼓楼区","17","6"); city[18]= new Array("青羊区","18","7"); city[19]= new Array("金牛区","19","7"); city[20]= new Array("武侯区","20","7"); city[21]= new Array("游仙区","21","8"); city[22]= new Array("培城区","22","8"); city[23]= new Array("朝天区","23","9"); city[24]= new Array("元坝区","24","9"); //把数组的值用数据库读出 document.form1.s2.length = 0; document.form1.s2.options[0]= new Option("请选择区","0"); j=1; for(i=1;i<=24;i++) { if(city[i][2]==num) {document.form1.s2.options[document.form1.s2.length]= new Option(city[i][0],city[i][1]);} j++} } </script> <script language="javascript"> function show(){ var obj=document.getElementByid("s2"); alert(obj.value); } </script> </head> <body> <form method="POST" action="<%=MM_editAction%>" name="form1" > <table align="center" > <tr valign="baseline"> <td nowrap align="right"><span class="STYLE4">籍贯:</span></td> <td> <select name="ss" class="STYLE4" onChange="bb(document.form1.ss.options[document.form1.ss.selectedIndex].value)" > <option value="0">请选择省</option> <option value="1">陕西</option> <option value="2">河南</option> <option value="3">四川</option> </select> <select name="s1" class="STYLE4" onChange="cc(document.form1.s1.options[document.form1.s1.selectedIndex].value)"> </select> <select name="s2" class="STYLE4" id="s2" onchange="show()"> </select> </td> </tr> </table> </form> <p> </p> </body> </html>
[ 本帖最后由 youthmeeter 于 2011-10-27 16:41 编辑 ]