2016/3/31 ①全选时 下面选项全选中 ② 下面不选中时 全选取消 ③在“” 中 转义字符的使用\ onclick=\"Checkpa(this,'flall')\"; ④区别于分别实现 重点在于两种情况合并实现
testxuanbuxuan.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<!-- <?php
@$qytj=$_POST["qy"];
@$zltj=$_POST["zl"];
@$fltj=$_POST["fl"];
@$key=$_POST["key"]; //造查询字符串
$st1=" 1=1";
$st2=" 1=1";
$st3=" 1=1";
$st4=" 1=1";
//判断第一个条件是否有值
if (count($qytj)>0) {
$ss=implode("','",$qytj);
$st1=" Area in ('$ss') ";
}
//依次判断第二三四个条件
if (count($zltj)>0) {
$zz=implode("','",$zltj);
$st2=" Renttype in ('$zz')";
}
if (count($fltj)>0) {
$ff=implode("','",$fltj);
$st3=" HouseType in ('$ff')";
}
if ($key!="") { $st4=" KeyWord like '%$key%'";
}
$sqltj=" where".$st1." and ".$st2." and ".$st3." and ".$st4; ?> -->
<form action="hhcheck.php" method="post">
<div>
<div>区域:
<input type="checkbox" id="qyall" name="qyall" onclick="CheckAll(this,'qy')" >全选
</div>
<div>
<?php
//1.造连接对象
$db=new mysqli("localhost","root","123","test2");
//2.判断是否连接成功
!mysqli_connect_error()or die("连接失败");
$sqlqy="select distinct(Area) from House";
$result=$db->query($sqlqy);
$arrqy=$result->fetch_all();
for ($i=0; $i <count($arrqy); $i++) {
echo "<div style='display:inline'><input type='checkbox' name='qy[]' class='qy' value='{$arrqy[$i][0]}' onclick=\"Checkpa(this,'qyall')\";>{$arrqy[$i][0]}</div> ";
}
?>
</div>
<br>
<div>租赁类型:
<input type="checkbox" id="zlall" name="zlall" onclick="CheckAll(this,'zl')">全选
</div>
<div>
<?php
//1.造连接对象
$db=new mysqli("localhost","root","123","test2");
//2.判断是否连接成功
!mysqli_connect_error()or die("连接失败");
$sqlzl="select distinct(Renttype) from House";
$result=$db->query($sqlzl);
$arrzl=$result->fetch_all();
for ($i=0; $i <count($arrzl); $i++) {
echo "<div style='display:inline'><input type='checkbox' name='zl[]' class='zl' value='{$arrzl[$i][0]}'onclick=\"Checkpa(this,'zlall')\";>{$arrzl[$i][0]}</div> ";
}
?>
</div>
<br>
<div>房屋类型:
<input type="checkbox" id="flall" name="fl[]" onclick="CheckAll(this,'fl')">全选
</div>
<div>
<?php
//1.造连接对象
$db=new mysqli("localhost","root","123","test2");
//2.判断是否连接成功
!mysqli_connect_error()or die("连接失败");
$sqlfl="select distinct(HouseType) from House";
$result=$db->query($sqlfl);
$arrfl=$result->fetch_all();
for ($i=0; $i <count($arrfl); $i++) {
echo "<div style='display:inline'><input type='checkbox' name='fl[]' class='fl' value='{$arrfl[$i][0]}' onclick=\"Checkpa(this,'flall')\";>{$arrfl[$i][0]}</div> ";
}
?>
</div>
<br>
<div>关键字:
<input type="text" name="key">
<input type="submit" value="搜索">
</div>
</div>
</form>
<table border="1" width=100% cellpadding="0" cellspacing="0">
<tr>
<td>关键字</td>
<td>区域</td>
<td>面积</td>
<td>租金</td>
<td>租赁类型</td>
<td>房屋类型</td>
</tr>
<?php
//1.造连接对象
$db=new mysqli("localhost","root","123","test2");
//2.判断是否连接成功
!mysqli_connect_error()or die("连接失败");
$sql="select * from House ".$sqltj;
$result=$db->query($sql);
$arral=$result->fetch_all();
for($i=0; $i<count($arral); $i++){
echo "<tr>
<td>{$arral[$i][1]}</td>
<td>{$arral[$i][2]}</td>
<td>{$arral[$i][3]}</td>
<td>{$arral[$i][4]}</td>
<td>{$arral[$i][5]}</td>
<td>{$arral[$i][6]}</td>
</tr>";
} ?>
</table>
</body>
<script>
function CheckAll(ck,list)
{ //找到全选按钮的选中状态
var zt=ck.checked;
//找到所有控制的checkbox
var all=document.getElementsByClassName(list);
//控制所有的checkbox状态和全选的状态一致
for (var i = 0; i < all.length; i++) {
all[i].checked=zt;
}
}
function Checkpa(pa,ids)
{
if(!pa.checked)
{ document.getElementById(ids).checked=
false; }
}
</script>
</html>
图1: 全选中
图2:有一个不选中,全选取消
2016/3/31 ①全选时 下面选项全选中 ② 下面不选中时 全选取消 ③在“” 中 转义字符的使用\ onclick=\"Checkpa(this,'flall')\"; ④区别于分别实现 重点在于两种情况合并实现的更多相关文章
- java项目打jar包的两种情况
链接地址:http://jingyan.baidu.com/article/6b97984d8a6ddc1ca2b0bfa0.html 本文介绍一下java项目打jar包时的两种情况各怎么操作 方 ...
- Hibernate多对多两种情况
Hibernate在做多对多映射的时候,除了原先的两张表外,会多出一个中间表做关联,根据中间表的会有两种不同的配置情况: 1.中间表不需要加入额外数据. 2.中间表有其他字段,需记录额外数据. 下面, ...
- 导致“mysql has gone away”的两种情况
导致“mysql has gone away”的两种情况 By Cruise 1. wait_timeout参数 在开发代理server时, 我使用了jdbc连接数据库,并采用长连接的方式连接数据库 ...
- Day6------------磁盘用满的两种情况
1.文件包含元数据和写入的内容 元数据:存在硬盘中的inode ls -i /etc/passwd.bak 查看inode df -i 查看inode 2.磁盘用满的两种情况 1).内容太多 2).空 ...
- JS获取元素宽高的两种情况
JS获取元素宽高分两种情况, 一.内联样式,也就是直接把width和height写在HTML元素中的style里: 这种情况使用 document.getElementById('xxx'). ...
- Nginx访问PHP文件的File not found错误处理,两种情况
这个错误很常见,原有有下面两种几种 1. php-fpm找不到SCRIPT_FILENAME里执行的php文件 2. php-fpm不能访问所执行的php,也就是权限问题 第一种情况 可以在你的loc ...
- django-将数据库数据转换成JSON格式(ORM和SQL两种情况)
最近打算搞一个自动化运维平台,所以在看Django的知识. 在实际项目开发中,遇到一个小问题:前后端发生数据交互主流采用的是JSON.前端传数据到服务器端比较简单,稍微麻烦的是服务器端传JSON到前端 ...
- zoj3228 Searching the String AC自动机查询目标串中模式串出现次数(分可覆盖,不可覆盖两种情况)
/** 题目:zoj3228 Searching the String 链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=34 ...
- Junit4使用详解一:测试失败的两种情况
Junit4最佳实践 1.把测试文件夹和代码文件夹分离,这两者的代码互不干扰,代码目录和测试目录是并列的关系 2.Java代码 3.创建单元测试代码文件 4.运行测试代码 5.查看测试结果 现在的情 ...
随机推荐
- 为公司内部搭建CA
步骤一 首先我们要知道CA的配置文件 openssl的配置文件:/etc/pki/tls/openssl.cnf 我们打开这个配置文件 这文件中很多跟CA相关的信息如图 解释: 我们可以搭建好几个CA ...
- LeetCode(34)Search for a Range
题目 Given a sorted array of integers, find the starting and ending position of a given target value. ...
- Cable master 求电缆的最大长度(二分法)
Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The J ...
- [MVC]在练习MusicStore过程中问题实录
1,问题描述:MVC在添加基于框架的控制器时,出现无法检索xxx的元数据 参考目录:http://www.cnblogs.com/0banana0/p/4050793.html#undefined 解 ...
- 如何将表的行数赋值给变量(MySQL)
delimiter $$ drop procedure if exists test_at $$ create definer=root@localhost procedure test_at() b ...
- Linux如何查看CPU负载
负载(load)是Linux机器的一个重要指标,直观了反应了机器当前的状态.如果机器负载过高,那么对机器的操作将难以进行. linux的负载高,主要是由于CPU使用.内存使用.IO消耗三部分构成.任意 ...
- php 压缩数据存储
php 压缩数据存储 当接收到大量的数据时,存储到数据库和从数据库读取时,时间都比较慢,所以压缩一下入库可能会好一点. 仅供参考!!! 封装的压缩数据函数: /** * 压缩数据 * @param s ...
- 一个APP的由来
之前在站酷.UI中国.优设等网站看过不少的APP教程.规范等一些东西.自认为有些规范讲的内容过于繁琐,对于像我这样的大多数设计师来说看着看着就懵逼了....
- Codeforces 653D Delivery Bears【二分+网络流】
题目链接: http://codeforces.com/problemset/problem/653/D 题意: x个熊拿着相同重量的物品,从1号结点沿着路走到N号结点,结点之间有边相连,保证可以从1 ...
- Search in Rotated Sorted Array(二分查找)
Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 migh ...