| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 437 人关注过本帖
标题:新手请教一个搜索页面问题,请高手帮忙
取消只看楼主 加入收藏
yhxkyhxk
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-4-10
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
新手请教一个搜索页面问题,请高手帮忙
我建立了两个页面 一个是城市选择页面 可以选择省市县,有一个提交按钮,我想实现一个功能,当我选择完县市以后点击提交自动读取县市对应的数值然后到数据库中查询,数据库中有一张表其中有一项的数值跟县市的数值相对应,根据选择的县市自动在第二个页面中显示这个县市所对应的内容。请大侠们帮忙看一下怎么解决
现在第一个页面已经写好了,代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<table width="800" height="600"  border="0" align="center">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="center" valign="middle"><SCRIPT LANGUAGE="JavaScript">
    function SelectGroup(PL, CL, AL){
        var _objPL = document.getElementById(PL);
        var _objCL = document.getElementById(CL);
        var _objAL = document.getElementById(AL);
        var strTemp = "请选择";
        var strVal = "0";
        var _1val = "";
        var _2val = "";
        var _3val = "";
        var _P = [];
                _P[0] = new Array("1", "北京");
                _P[1] = new Array("2", "安徽");
                _P[2] = new Array("3", "福建");
                _P[3] = new Array("4", "甘肃");
                _P[4] = new Array("5", "广东");
                _P[5] = new Array("6", "广西");
                _P[6] = new Array("7", "贵州");
                _P[7] = new Array("8", "海南");
                _P[8] = new Array("9", "河北");
                _P[9] = new Array("10", "河南");
                _P[10] = new Array("11", "黑龙江");
                _P[11] = new Array("12", "湖北");
                _P[12] = new Array("13", "湖南");
                _P[13] = new Array("14", "吉林");
                _P[14] = new Array("15", "江苏");
                _P[15] = new Array("16", "江西");
                _P[16] = new Array("17", "辽宁");
                _P[17] = new Array("18", "内蒙古");
                _P[18] = new Array("19", "宁夏");
                _P[19] = new Array("20", "青海");
                _P[20] = new Array("21", "山东");
                _P[21] = new Array("22", "山西");
                _P[22] = new Array("23", "陕西");
                _P[23] = new Array("24", "上海");
                _P[24] = new Array("25", "四川");
                _P[25] = new Array("26", "天津");
                _P[26] = new Array("27", "西藏");
                _P[27] = new Array("28", "新疆");
                _P[28] = new Array("29", "云南");
                _P[29] = new Array("30", "浙江");
                _P[30] = new Array("31", "重庆");

        var _C = [];
                _C[0] = new Array("1", "1", "北京");
                //安徽省
                _C[1] = new Array("2", "2", "安庆");
                _C[2] = new Array("2", "3", "蚌埠");
                _C[3] = new Array("2", "4", "巢湖");
                _C[4] = new Array("2", "5", "池州");
                _C[5] = new Array("2", "6", "滁州");
                _C[6] = new Array("2", "7", "阜阳");
                _C[7] = new Array("2", "8", "合肥");
               _C[8] = new Array("2", "9", "淮北");
               _C[9] = new Array("2", "10", "淮南");
               _C[10] = new Array("2", "11", "黄山");
               _C[11] = new Array("2", "12", "六安");
               _C[12] = new Array("2", "13", "马鞍山");
               _C[13] = new Array("2", "14", "宿州");
               _C[14] = new Array("2", "15", "铜陵");
               _C[15] = new Array("2", "16", "芜湖");
               _C[16] = new Array("2", "17", "宣城");
               _C[17] = new Array("2", "18", "毫州");
               var _A = [];   //北京市  
                _A[0] = new Array("1", "1", "东城");
                _A[1] = new Array("1", "2", "西城");
                _A[2] = new Array("1", "3", "崇文");
                _A[3] = new Array("1", "4", "宣武");
                _A[4] = new Array("1", "5", "朝阳");
                _A[5] = new Array("1", "6", "丰台");
                _A[6] = new Array("1", "7", "石景山");
                _A[7] = new Array("1", "8", "海淀");
                _A[8] = new Array("1", "9", "门头沟");
                _A[9] = new Array("1", "10", "房山");
                _A[10] = new Array("1", "11", "通州");
                _A[11] = new Array("1", "12", "顺义");
                _A[12] = new Array("1", "13", "昌平");
                _A[13] = new Array("1", "14", "大兴");
                _A[14] = new Array("1", "15", "平谷");
                _A[15] = new Array("1", "16", "怀柔");
                _A[16] = new Array("1", "17", "密云");
                _A[17] = new Array("1", "18", "延庆");
                //安徽省安庆市
                _A[18] = new Array("2", "19", "怀宁");
                _A[19] = new Array("2", "20", "潜山");
                _A[20] = new Array("2", "21", "宿松");
                _A[21] = new Array("2", "22", "太湖");
                _A[22] = new Array("2", "23", "桐城");
                _A[23] = new Array("2", "24", "望江");
                _A[24] = new Array("2", "25", "岳西");
                _A[25] = new Array("2", "26", "枞阳");
                _A[26] = new Array("2", "27", "迎江");
                _A[27] = new Array("2", "28", "大观");
                _A[28] = new Array("2", "29", "郊区");
               //安徽省蚌埠市
                _A[29] = new Array("3", "30", "蚌山区");
                _A[30] = new Array("3", "31", "龙子湖区");
                _A[31] = new Array("3", "32", "禹会区");
                _A[32] = new Array("3", "33", "淮上区");
                _A[33] = new Array("3", "34", "怀远县");
                _A[34] = new Array("3", "35", "五河县");
                _A[35] = new Array("3", "36", "固镇县");
                  //安徽省巢湖市
                _A[36] = new Array("4", "37", "巢湖区");
                _A[37] = new Array("4", "38", "庐江县");
                _A[38] = new Array("4", "39", "无为县");
                _A[39] = new Array("4", "40", "含山县");
                _A[40] = new Array("4", "41", "和县");
                //安徽省池州市
                _A[41] = new Array("5", "42", "贵池区");
                _A[42] = new Array("5", "43", "东至县");
                _A[43] = new Array("5", "44", "青阳县");
                _A[44] = new Array("5", "45", "石台县");
                //安徽省滁州市
                _A[45] = new Array("6", "46", "琅琊区");
                _A[46] = new Array("6", "47", "南谯区");
                _A[47] = new Array("6", "48", "来安县");
                _A[48] = new Array("6", "49", "明光县");
                _A[49] = new Array("6", "50", "全椒县");
                _A[50] = new Array("6", "51", "天长县");
                _A[51] = new Array("6", "52", "定远县");
                _A[52] = new Array("6", "53", "凤阳县");
               //安徽省阜阳县
                _A[53] = new Array("7", "54", "颖州区");
                _A[54] = new Array("7", "55", "颖东区");
                _A[55] = new Array("7", "56", "颖泉区");
                _A[56] = new Array("7", "57", "临泉县");
                _A[57] = new Array("7", "58", "太和县");
                _A[58] = new Array("7", "59", "阜南县");
                _A[59] = new Array("7", "60", "颍上县");
                _A[60] = new Array("7", "61", "界首市");
                //安徽省合肥市            
                _A[61] = new Array("8", "62", "巢湖市");
                _A[62] = new Array("8", "63", "肥东县");
                _A[63] = new Array("8", "64", "肥西县");
                _A[64] = new Array("8", "65", "长丰县");
                _A[65] = new Array("8", "66", "庐江县");
                //安徽省淮北市
                _A[66] = new Array("9", "67", "杜集区");
                _A[67] = new Array("9", "68", "相山区");
                _A[68] = new Array("9", "69", "烈山区");
                _A[69] = new Array("9", "70", "濉溪县");
                //安徽省淮南市
                _A[70] = new Array("10", "71", "大通区");
                _A[71] = new Array("10", "72", "田家庵区");
                _A[72] = new Array("10", "73", "谢家集区");
                _A[73] = new Array("10", "74", "八公山区");
                _A[74] = new Array("10", "75", "凤台县");
                //安徽省黄山市
                _A[75] = new Array("10", "76", "屯溪区");
                _A[76] = new Array("10", "77", "黄山区");
                _A[77] = new Array("10", "78", "徽州区");
                _A[78] = new Array("10", "79", "歙县");
                _A[79] = new Array("10", "80", "休宁县");
                _A[80] = new Array("10", "81", "黟县");
                _A[81] = new Array("10", "82", "祁门县");
           

        this.IntIndex = function(_PLval, _CLval, _ALval){
                _objPL.options[0] = new Option(strTemp, strVal);
                _objCL.options[0] = new Option(strTemp, strVal);
                _objAL.options[0] = new Option(strTemp, strVal);
                if (!isNaN(_PLval) && !isNaN(_CLval) && !isNaN(_ALval)){
                        _1val = _PLval;
                        _2val = _CLval;
                        _3val = _ALval;
                        _AddP();
                        _AddC(_PLval);
                        _AddA(_CLval);
                }
                else
                { _AddP(); }
        }

        _AddP = function(){
                if (!isNaN(_objPL)){alert("对象ID设置错误."); return false;}
                _objPL.length = 1;
                _objPL.selectedIndex = 0
                for (var i=0; i<_P.length; i++){
                        var OPP = document.createElement("OPTION");
                        OPP.innerHTML = _P[i][1];
                        OPP.value = _P[i][0];
                        _objPL.appendChild(OPP);
                }
                if (!isNaN(_1val)){
                        for(var x=0; x<_objPL.length; x++){
                                if (_1val==_objPL.options[x].value) _objPL.options[x].selected = true;
                        }
                }
                _objPL.onchange = function(){
                        _AddC(this.value);
                }
        };

        _AddC = function(load){
                if (!isNaN(_objCL) || !isNaN(_objAL)){alert("对象ID设置错误."); return false;}
                _objCL.length = 1;
                _objCL.selectedIndex = 0
                _objAL.length = 1;
                _objAL.selectedIndex = 0
                for (var i=0; i<_C.length; i++){
                        if (_C[i][0]==load){
                                var OPP = document.createElement("OPTION");
                                OPP.innerHTML = _C[i][2];
                                OPP.value = _C[i][1];
                                _objCL.appendChild(OPP);
                        }
                }
        

                if (!isNaN(_2val)){
                        for(var x=0; x<_objCL.length; x++){
                                if (_2val==_objCL.options[x].value) _objCL.options[x].selected = true;
                        }
                }
                _objCL.onchange = function(){
                        _AddA(this.value);
                }
        };

        _AddA = function(load){
                _objAL.length = 1;
                _objAL.selectedIndex = 0
                for (var i=0; i<_A.length; i++){
                        if (_A[i][0]==load){
                                var OPP = document.createElement("OPTION");
                                OPP.innerHTML = _A[i][2];
                                OPP.value = _A[i][1];
                                _objAL.appendChild(OPP);
                        }
                }

                if (!isNaN(_3val)){
                        for(var x=0; x<_objAL.length; x++){
                                if (_3val==_objAL.options[x].value) _objAL.options[x].selected = true;
                        }
                }
        };

}//end class

//-->
    </SCRIPT>
<form name="form1" method="post" action="xs.asp">
<select name="s1" size="1" id="s1">
</select>

<select name="s2" size="1" id="s2">
</select>
区/市:
<select name="s3" size="1" id="s3">
</select>
县/市
<input type="submit" name="Submit" value="提交">
   
      </form>
            </td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<SCRIPT LANGUAGE="JavaScript">
<!--
var s = new SelectGroup("s1","s2","s3");
s.IntIndex();
s = null;
//-->
</SCRIPT>
</body>
</html>
显示页面代码
<table width="100%"  border="1">
  <tr>
    <td>编号</td>
    <td>姓名</td>
    <td>电话</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
数据库中表名叫mymingche  包括my_id  my_name my_tel
现在想根据my_id来查询相应内容  请大侠帮帮忙
搜索更多相关主题的帖子: 数据库 html content PUBLIC 
2012-04-10 12:37
yhxkyhxk
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-4-10
收藏
得分:0 
为啥没人理我呢
2012-04-10 18:15
快速回复:新手请教一个搜索页面问题,请高手帮忙
数据加载中...
 
   



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

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