• 三级联动菜单


    html

    <p>
                      <label>区域</label>
                    <select name="province" id="province" onchange="region('province','city','1')">
                        <option value="">省份</option>
                        {$region_province}
                    </select>
                    <select name="city" id="city" onchange="region('city','district','2')">
                         <option value="">地级市</option>
                        
                    </select>
                    <select name="district" id="district">
                         <option value="">市、县级市</option>
                      
                    </select>
                    
                  </p>

    js

    <script type="text/javascript">
                  function region(t,p,type){ 
                    var a =document.getElementById(t).value;                  
                      $.ajax({
                            url: "index.php?action=ajax_region&parent_id="+a+"&retion_type="+type,
                            success: function(html){
                                html += "<option value=''>请选择</option>";
                                $("#"+p).html(html)
                            }
                      });
                  }
                  </script>

    ajax,php代码

    function region($parent_id,$region_type){           //region(0,北京市)
        $where = "where parent_id = $parent_id";
        
        $sql = mysql_query("select * from rv_region $where");
        //echo $where;
        while($re = mysql_fetch_row($sql)){
            $arr[] = $re;    
        }
        if($region_type =='1'){
            $province .= "<option value=''>地级市</option>";
        }else if($region_type =='2'){
            $province .= "<option value=''>市、县级市</option>";    
        }
        
        foreach($arr as $k=>$val){
            $province .= "<option value='".$val[0]."'>".$val[2]."</option>";
            
        }
        
        return $province;
    }   
    
    $parent_id = $_GET['parent_id'];
    $region_type = $_GET['retion_type'];
        
    echo region($parent_id,$region_type);

    三级联动mysql数据

  • 相关阅读:
    k8s pod 定义 文件 yaml
    动态规划(1)
    Angular封装WangEditor富文本组件
    使用Angular CDK实现一个Service弹出Toast组件
    让Angular自定义组件支持form表单验证
    等了半年,m1芯片原生支持的.NET IDE出现了
    eachrt
    dgy
    开源节流
    company
  • 原文地址:https://www.cnblogs.com/wesky/p/3438139.html
Copyright © 2020-2023  润新知