php结合js实现多条件组合查询


Posted in Javascript onMay 28, 2019

 本文实例为大家分享了php结合js实现多条件组合查询的具体代码,供大家参考,具体内容如下

一、效果图

php结合js实现多条件组合查询

二、前端代码

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Jquery分类</title> 
<script src="http://libs.baidu.com/jquery/1.7.2/jquery.min.js"></script>
<style type="text/css"> 
 .templinkactive { 
 padding:5px; 
 text-decoration:none; 
 color:red; 
 } 
 .templink { 
 cursor:pointer; 
 padding:5px; 
 text-decoration:none; 
 } 
 table{border:1px solid #ccc;}
 table tr{ height:35px;} 
</style>
<script type="text/javascript"> 
 $(function () { 
 //品牌 
 var alink01 = $("#linktype01").find("span"); 
 alink01.click(function () { 
 alink01.each(function () { 
 $(this).removeClass("templinkactive").addClass("templink"); 
 }); 
 $(this).removeClass("templink").addClass("templinkactive"); 
 $("#Brand").val($(this).attr("tag"));
 SetPara();
 });

 //价格 
 var alink02 = $("#linktype02").find("span"); 
 alink02.click(function () { 
 alink02.each(function () { 
 $(this).removeClass("templinkactive").addClass("templink"); 
 }); 
 $(this).removeClass("templink").addClass("templinkactive"); 
 $("#Price").val($(this).attr("tag"));
 SetPara();
 }) 

 //尺寸 
 var alink03 = $("#linktype03").find("span"); 
 alink03.click(function () { 
 alink03.each(function () { 
 $(this).removeClass("templinkactive").addClass("templink"); 
 }); 
 $(this).removeClass("templink").addClass("templinkactive"); 
 $("#Size").val($(this).attr("tag")); 
 SetPara(); 
 }); 
 }); 

 function SetPara() { 
 var Brand = $("#Brand").val(); 
 var Price = $("#Price").val(); 
 var Size = $("#Size").val(); 
 alert("1.php?Brand=" + Brand + "&Price=" + Price + "&Size=" + Size); 
 // var keywords = $("#search").val();
  // var skip_url = "http://" + window.location.hostname + window.location.pathname;
  // var url = skip_url + "?s=/admin/goods/goods_list/Brand/"+Brand+"/Price/"+Price+"/Size/"+Size;
  // window.location.href = url;
  // alert(url); 
 }; 
</script>
<script type="text/javascript">
 /*//TP框架-start
 $(function(){
  var Brand = $("#Brand").val();
  var Price = $("#Price").val();
  var Size = $("#Size").val();
  // alert(tag);
  if(Brand != ''){
   $("#linktype01").find("span").removeClass("templinkactive").addClass("templink")
   $('span[tag="'+Brand+'"]').css('color','red');
  }
  if(Price != ''){
   $("#linktype02").find("span").removeClass("templinkactive").addClass("templink")
   $('span[tag="'+Price+'"]').css('color','red');
  }
  if(Size != ''){
   $("#linktype03").find("span").removeClass("templinkactive").addClass("templink")
   $('span[tag="'+Size+'"]').css('color','red');
  }
 });
 //TP框架-end*/
</script>
</head> 
<body> 
 <form id="form1" runat="server"> 
 <div> 
 <table> 
 <tr id="linktype01"> 
  <td style="width:100px"> 
  <b>笔记本品牌</b> 
  </td> 
  <td> 
  <span class='templinkactive' tag="0">不限</span> 
  </td> 
  <td> 
  <span class='templink' tag="100101">联想(Lenovo)</span> 
  </td> 
  <td> 
  <span class='templink' tag="100102">宏?(Acer)</span> 
  </td> 
  <td> 
  <span class='templink' tag="100103">华硕(ASUS)</span> 
  </td> 
  <td> 
  <span class='templink' tag="100104">戴尔(DELL)</span> 
  </td> 
  <td> 
  <span class='templink' tag="100105">苹果(Apple)</span> 
  </td> 
  <td> 
  <span class='templink' tag="100106">三星 (SAMSUNG)</span> 
  </td> 
 </tr> 
 <tr id="linktype02"> 
  <td style="width:100px"> 
  <b>价格范围</b> 
  </td> 
  <td> 
  <span class='templinkactive' tag="0">不限</span> 
  </td> 
  <td> 
  <span class='templink' tag="100201">1000-2999</span> 
  </td> 
  <td> 
  <span class='templink' tag="100202">3000-3499</span> 
  </td> 
  <td> 
  <span class='templink' tag="100203">4000-4499</span> 
  </td> 
  <td>
  <span class='templink' tag="100204">5000-5999</span>
  </td>
  <td>
  <span class='templink' tag="100205">6000-6999</span>
  </td>
  <td>
  <span class='templink' tag="100206">7000及以上</span>
  </td>
 </tr>
 <tr id="linktype03">
  <td style="width:100px">
  <b>尺寸范围</b>
  </td>
  <td>
  <span class='templinkactive' tag="0" >不限</span>
  </td>
  <td>
  <span class='templink' tag="100301">8.9英寸及以下</span>
  </td>
  <td>
  <span class='templink' tag="100302">11英寸</span>
  </td>
  <td>
  <span class='templink' tag="100303">12英寸</span>
  </td>
  <td>
  <span class='templink' tag="100304">13英寸</span>
  </td>
  <td>
  <span class='templink' tag="100305">14英寸</span>
  </td>
  <td>
  <span class='templink' tag="100306">15英寸及以上</span>
  <input type="hidden" id="Brand" value="" />
  <input type="hidden" id="Price" value="" />
  <input type="hidden" id="Size" value="" />
  </td> 
 </tr> 
 </table> 
 </div> 
 </form> 
</body> 
</html>

三、服务端代码

goodsController.class.php

<?php
public function goods_list(){
 $Brand= I('Brand');
 $Price= I('Price');
 $Size= I('Size');
 $this->assign('Brand',$Brand);
 $this->assign('Price',$Price);
 $this->assign('Size',$Size);
 $this->display();
}
?>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

Javascript 相关文章推荐
js 内存释放问题
Apr 25 Javascript
json属性名为什么要双引号(个人猜测)
Jul 31 Javascript
jquery实现Ctrl+Enter提交表单的方法
Jul 21 Javascript
小巧强大的jquery layer弹窗弹层插件
Dec 06 Javascript
JavaScript 不支持 indexof 该如何解决
Mar 30 Javascript
JavaScript判断是否是微信浏览器
Jun 13 Javascript
BootStrap整体框架之基础布局组件
Dec 15 Javascript
AngularJS表格样式简单设置方法示例
Mar 03 Javascript
jQuery+PHP+Mysql实现抽奖程序
Apr 12 jQuery
node作为中间服务层如何发送请求(发送请求的实现方法详解)
Jan 02 Javascript
element-ui上传一张图片后隐藏上传按钮功能
May 22 Javascript
正则表达式基础与常用验证表达式
Jun 16 Javascript
vue实现前台列表数据过滤搜索、分页效果
May 28 #Javascript
js 将线性数据转为树形的示例代码
May 28 #Javascript
React中使用外部样式的3种方式(小结)
May 28 #Javascript
vue实现多条件和模糊搜索功能
May 28 #Javascript
vue实现路由切换改变title功能
May 28 #Javascript
Vue 无限滚动加载指令实现方法
May 28 #Javascript
vue实现搜索过滤效果
May 28 #Javascript
You might like
php仿discuz分页效果代码
2008/10/02 PHP
php ob_flush,flush在ie中缓冲无效的解决方法
2010/05/09 PHP
php基础设计模式大全(注册树模式、工厂模式、单列模式)
2015/08/31 PHP
Yii框架实现多数据库配置和操作的方法
2017/05/25 PHP
PHP与以太坊交互详解
2018/08/24 PHP
thinkPHP+LayUI 流加载实现功能
2019/09/27 PHP
说说JSON和JSONP 也许你会豁然开朗
2012/09/02 Javascript
js清除input中type等于file的值域(示例代码)
2013/12/24 Javascript
jQuery获得页面元素的绝对/相对位置即绝对X,Y坐标
2014/03/06 Javascript
jQuery基于ajax实现星星评论代码
2015/08/07 Javascript
JavaScript设计模式经典之命令模式
2016/02/24 Javascript
JS实现复制内容到剪贴板功能
2017/02/05 Javascript
JavaScript中运算符规则和隐式类型转换示例详解
2017/09/06 Javascript
基于Axios 常用的请求方法别名(详解)
2018/03/13 Javascript
JavaScript事件循环及宏任务微任务原理解析
2020/09/02 Javascript
[01:19:46]DOTA2-DPC中国联赛 正赛 SAG vs DLG BO3 第一场 2月28日
2021/03/11 DOTA
python中正则表达式的使用详解
2014/10/17 Python
python简单程序读取串口信息的方法
2015/03/13 Python
Python+django实现文件上传
2016/01/17 Python
python自动登录12306并自动点击验证码完成登录的实现源代码
2018/04/25 Python
Python实现的NN神经网络算法完整示例
2018/06/19 Python
python 中字典嵌套列表的方法
2018/07/03 Python
Python之循环结构
2019/01/15 Python
手把手教你Python yLab的绘制折线图的画法
2019/10/23 Python
pytorch实现onehot编码转为普通label标签
2020/01/02 Python
虚拟环境及venv和virtualenv的区别说明
2021/02/05 Python
深入探究HTML5的History API
2015/07/09 HTML / CSS
自荐信格式简述
2014/01/25 职场文书
春节晚会主持词
2014/03/24 职场文书
学习雷锋标语
2014/06/25 职场文书
计划生育诚信协议书
2014/11/02 职场文书
先进事迹材料范文
2014/12/29 职场文书
涪陵白鹤梁导游词
2015/02/09 职场文书
2015年关爱留守儿童工作总结
2015/05/22 职场文书
学生早退检讨书(范文)
2019/08/19 职场文书
python小型的音频操作库mp3Play
2022/04/24 Python