
正文
条件查询,有input和select框,当查询条件获取焦点时支持摁下enter键查询
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
<%@ 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=">高</option> <option value=">中</option> <option value=">低</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="> <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(p.flag){ alert("查询"); $("#search").submit(); } } }, initSearch:function(){ var $inputs = $("#search input"); p.bindFB($inputs); var $selects = $("#search select"); p.bindFB($selects); }, bindFB:function($flags){ ;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的样式去除“清空查询条件按钮”的回车键查询功能







