zoukankan      html  css  js  c++  java
  • 补2017.5.14

    三级联动

    <script src="jquery-1.8.2.min.js"></script>
    <script src="Area.js"></script>
    </head>

    <body>
    <h1>显示数据</h1>

    <select id="sel1">

    </select>
    <select id="sel2">

    </select>
    <select id="sel3">

    </select>

    </body>
    <script type="text/javascript">
    $(document).ready(function(e) {

    //异步AJAX
    //异步和同步
    var pcode = "0001";

    $.ajax({
    async:false,
    url:"chuli1.php",
    data:{pcode:pcode},
       type:"POST",
    dataType:"TEXT",
    complete: function(){},
    beforeSend: function(){},
    error: function(){},
    success: function(data){
    var hang = data.split("|");
    var str = "";
    for(var i=0;i<hang.length;i++)
    {
    var lie = hang[i].split("^");
    str = str +"<option value='"+lie[0]+"'>"+lie[1]+"</option>";
    }
    $("#sel1").html(str);

    }
    });

    });
    </script>
    <script type="text/javascript">
    $(document).ready(function(e) {

    //异步AJAX
    //异步和同步
    var pcode = "11";

    $.ajax({
    async:false,
    url:"chuli2.php",
    data:{pcode:pcode},
       type:"POST",
    dataType:"TEXT",
    complete: function(){},
    beforeSend: function(){},
    error: function(){},
    success: function(data){
    var hang = data.split("|");
    var str = "";
    for(var i=0;i<hang.length;i++)
    {
    var lie = hang[i].split("^");
    str = str +"<option value='"+lie[0]+"'>"+lie[1]+"</option>";
    }
    $("#sel2").html(str);

    }
    });

    });
    </script>
    <script type="text/javascript">
    $(document).ready(function(e) {

    //异步AJAX
    //异步和同步
    var pcode = "1101";

    $.ajax({
    async:false,
    url:"chuli3.php",
    data:{pcode:pcode},
       type:"POST",
    dataType:"TEXT",
    complete: function(){},
    beforeSend: function(){},
    error: function(){},
    success: function(data){
    var hang = data.split("|");
    var str = "";
    for(var i=0;i<hang.length;i++)
    {
    var lie = hang[i].split("^");
    str = str +"<option value='"+lie[0]+"'>"+lie[1]+"</option>";
    }
    $("#sel3").html(str);

    }
    });

    });

    注意好同步和异步。

    chuli1的代码

    //给我一个父级代号,返回该父级代号下所有的子地区

    <?php
    $pocde=$_POST["pcode"];
    require "./DBDA.class.php";
    $db = new DBDA();

    $sql = "select areacode,areaname from chinastates where parentareacode='{$pocde}'";

    echo $db->strquery($sql);

  • 相关阅读:
    凡是可能出错的事必定会出错
    php session 前后台同域名下
    mysql常用; group by 高级
    Thread 学习记录 <1> -- volatile和synchronized
    VBA学习
    EXPLAINING WHAT ACTION AND FUNC ARE
    Unslider.js Tiny Sample
    jQuery操作DOM元素
    在.net中使用GAC
    Sql Server 分区演练 【转】
  • 原文地址:https://www.cnblogs.com/nzhcww/p/6906855.html
Copyright © 2011-2022 走看看