<!DOCTYPE HTML> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" href="__PUBLIC__/Wechat/css/choose.css?20150819" rel="external nofollow" type="text/css"> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js" type="text/javascript"></script> <title>选择所在学校</title> </head> <body style="overflow:-Scroll;overflow-x:hidden"> <div class="title"> 请选择您所在学校 </div> <div class="search-w"> <input class="search" type="text" name="k" placeholder="快速搜索您所在的城市或学校" value=""> <!--需要动态显示的数据列表框--> <ul class="list"> </ul> </div> <div class="wraper"> <div class="center"> <div class="left"> <ul> <!--显示所有的省份--> <foreach name="cityList" item="city"> <li id="box{$city.id}"><a href="__APP__/School/index/cityid/{$city.id}" rel="external nofollow" >{$city.name}</a></li> </foreach> </ul> </div> <div class="right"> <!--显示所有城市 --> <foreach name="countyList" item="county"> <ul> <p>{$county.name}</p> <!--显示城市里面的学校--> <foreach name="county['school']" item="school"> <li><a href="__APP__/Dormitory/index/sid/{$school.sid}" rel="external nofollow" >{$school.name}</a></li> </foreach> </ul> </foreach> </div> </div> </div> </body> <script> $(function(){ //响应键盘事件 $('.search-w input[name="k"]').keyup(function(){ //发送post请求,地址为控制器中的get_school_by_key方法,参数为输入的内容 $.post('__APP__/School/get_school_by_key',{'key':$(this).val()},function(data){ var data = eval('('+data+')'); //如果数据不为空 if(data.flag){ //清空ul中的数据并显示 $(".list").empty(); $('.list').css('display','block'); // 循坏遍历返回值,并添加到li中 $(data.data).each(function(position){ $(".list").append("<li><a href='__APP__/Dormitory/index/sid/"+data.data[position].sid+"'>"+data.data[position].name+"</a></li>"); }); }else{ //不显示 $('.list').css('display','none'); } }); }); }); </script> </html>
- css样式表(choose.css)
/* CSS Document */ * { margin:0; padding:0; } body { background:#FBFBFB; width:100%; } ul { list-style:none; } a { text-decoration:none; } .right ul li a:active { color:#FF5C57; } .left ul li a:active { color:#FF5C57; } .right ul li a:hover { color:#FF5C57; } .left ul li a:hover { color:#FF5C57; } .title { background:#C32D32; height:50px; width:100%; line-height:50px; text-align:center; font-family:Arial, Helvetica, sans-serif; font-size:18px; color:#FFF; } .search-w { text-align:center; width:100%; height:50px; } .search { width:95%; height:30px; text-align:center; margin-top:1%; border:#ccc 1px solid; font-size:14px; background: #FFF url(image/s1.png) no-repeat 15% 5px; } .list { width:95%; text-align:left; border:#ccc 1px solid; font-size:14px; margin:0 auto; background:#FFF; position:relative; } .list li { height:35px; width:100%; line-height:35px; border-bottom:#DFDFDF 1px solid; } .list li a{color:#939393; width:100%; height:100%; display:block;} .list li a:hover { color:#ff5c57; } .wraper{ width: 100%; height:100%; } .center{ width:95%; height:100%; } .left { margin-top:5px; width:19.9%; background:#FBFBFB; float:left; border-top:#DFDFDF 1px solid; overflow:hidden; } .left ul { width:100%; height:100%; } .left ul li { height:60px; line-height:60px; border-bottom:#F1F1F1 1px solid; text-align:center; border-right:1px solid #C0C0C0; } .left ul li a { color:#939393; font-weight: bold; height:100%; width:100%; display:block; } .right { margin-top:5px; width:80%; background:#FFF; float:left; border-top:#DFDFDF 1px solid; } .right ul li a { padding-left: 5%; color:#939393; height:100%; width:95%; display:block; } .right ul { width:100%; height:100%; } .right ul li { height:45px; line-height:45px; width:100%; text-align:left; border-bottom:#E8E8E8 1px solid; color:#7C7C7C; } .right ul p{ height:45px; line-height:45px; width:100%; text-align:center; border-bottom:#E8E8E8 1px solid; color:#939393; font-weight: bold; font-size: 18px; }
内容版权声明:除非注明,否则皆为本站原创文章。