| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 851 人关注过本帖
标题:表格里三级联动取第三个下拉框值的问题
只看楼主 加入收藏
youthmeeter
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2011-10-20
结帖率:57.14%
收藏
已结贴  问题点数:10 回复次数:3 
表格里三级联动取第三个下拉框值的问题
做了个插入资料的页面,在选择籍贯时通过三级联动来选择,联动做的对着,能看到选的值,但是选的值无法赋给单元格,
 省(陕西)-->市(西安)-->区(未央),需要把“未央区”赋值给“籍贯”这个字段,数据库表是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>&nbsp;</p>
</body>
</html>



[ 本帖最后由 youthmeeter 于 2011-10-27 16:41 编辑 ]
搜索更多相关主题的帖子: 数据库表 html PUBLIC 未央区 陕西 
2011-10-27 16:39
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:10 
<!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);
}
function Birthplace_Click()
{
    //.value是取值而.text是文本
    var Province=document.form1.ss.options[document.form1.ss.selectedIndex].text;
    var City=document.form1.s1.options[document.form1.s1.selectedIndex].text;
    var Area=document.form1.s2.options[document.form1.s2.selectedIndex].text;
    alert(Province+"省"+City+"市"+Area+"区");
}
</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>
      <input type="button" name="Birthplace" onclick="Birthplace_Click();" value="显示籍贯"/>
      </td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
</body>
</html>
2011-10-28 21:33
youthmeeter
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2011-10-20
收藏
得分:0 
回复 2楼 yms123
alert(Province+"省"+City+"市"+Area+"区");
这句应该是在弹出框显示“省市区”,我不想让他弹出显示,我只需要把区(AREA)这个文本赋值给表YHSJ中的JG字段,语句该怎么写?谢谢!
2011-10-29 00:11
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
以下是引用youthmeeter在2011-10-29 00:11:51的发言:

alert(Province+"省"+City+"市"+Area+"区");
这句应该是在弹出框显示“省市区”,我不想让他弹出显示,我只需要把区(AREA)这个文本赋值给表YHSJ中的JG字段,语句该怎么写?谢谢!
获得的值之后提交表单后保存到数据库即可
2011-10-29 13:46
快速回复:表格里三级联动取第三个下拉框值的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.036689 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved