码迷,mamicode.com
首页 > 其他好文 > 详细

条件查询,有input和select框,当查询条件获取焦点时支持摁下enter键查询

时间:2015-06-15 00:06:12      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
 <link
    href="${pageContext.request.contextPath }/css/bootstrap.css"
    type="text/css" rel="stylesheet" />
<script type="text/javascript"
    src="${pageContext.request.contextPath }/js/jquery-1.10.2.js"></script>
<script type="text/javascript"
    src="${pageContext.request.contextPath }/js/bootstrap.js"></script>
</head>
<body>
<form id="search" action="${pageContext.request.contextPath }/keypress" method="post" onkeyup="p.search(event)">
<table class="table">
    <tr>
        <td>
            告警级别
        </td>
        <td>
            <select name="level">
                <option value="">全部</option>
                <option value="1">高</option>
                <option value="2">中</option>
                <option value="3">低</option>
            </select>
        </td>
        <td>
            告警流水号
        </td>
        <td>
            <input type="text" name="serialNo"/>
        </td>
    </tr>
    <tr>
        <td>告警标题</td>
        <td>
            <input type="text" name="title"/>
        </td>
        <td>上报时间</td>
        <td>
            <input type="text" name="uploadTime"/>
        </td>
    </tr>
    <tr>
        <td colspan="4">
            <input class="btn btn-primary btn-sm" type="button" value="查询"/>
            <a class="btn btn-primary btn-sm"  href="javascript:void(0);" onclick="">清空查询条件</a>
        </td>
    </tr>
</table>
</form>
<form action="">

</form>
</body>
<script type="text/javascript">
$(function(){
    p.initSearch();
});
var p = {
      flag:false,
      search:function(event){
         if(event.keyCode==13){
            if(p.flag){
                alert("查询");
                $("#search").submit();
            }
         }
      },
      initSearch:function(){
          var $inputs = $("#search input");
          p.bindFB($inputs);
          var $selects = $("#search select");
          p.bindFB($selects);
      },
      bindFB:function($flags){
          for(var i=0;i<$flags.length;i++){
                var $flag=$($flags.get(i));
                $flag.bind({
                    "focus":function(){
                        p.flag=true;
                    },
                    "blur":function(){
                        p.flag=false;
                    }
                });
            }
      },
      clearCondition:function(){
          alert("clear");
      }
}
</script>
</html>

利用bootstrap的样式去除“清空查询条件按钮”的回车键查询功能

条件查询,有input和select框,当查询条件获取焦点时支持摁下enter键查询

标签:

原文地址:http://www.cnblogs.com/qq931399960/p/4575837.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!