web页面之搜索、高级搜索功能

功能概述

       web页面开发中,常见根据输入关键字搜索查询信息,如淘宝网、百度等的搜索,同时还附有包含多输入域条件的高级查询,这样的页面效果很常见。下面介绍一下我的开发方法。

页面效果

        待补充。

源码构件

1.引入js库、样式
<script type="text/javascript" src="<%=path%>/js/jquery.js"></script>
2.页面代码如下:
<div class="cwbt"> 
<input type="text" name="anytext" id="anytext" size="50"  value="<s:property value='#request.anytextReq' />"/>&nbsp;
<input type="button" value="查询" class="btnm" οnclick="queryAny()"/>&nbsp;
<input type="button" value="高级查询"  οnclick="to_queryMore();" class="btnm"/>&nbsp;
</div>

3.js代码如下:
$(function() {
 //初始化查询条件
 initQueryCond();
});
//初始化查询条件
function initQueryCond(){
 var anytextReq="<s:property value='#request.anytextReq' />";
 var queryMode="<s:property value='#request.queryMode' />";//查询模式
 var anytextValue = "用户名";//关键字指定
 if(anytextReq==""){
   $("#anytext").val(anytextValue);
   $("#anytext").attr("style","color:#D5D5D5");
 }
 if(queryMode=="more"){//查询模式的判断
 showDiv("queryCondition");
 }else{
 closeDiv("queryCondition");
 }
 
 $("#anytext").click(function(){
    if($("#anytext").val()==anytextValue){
 $("#anytext").val("");
}
$("#anytext").attr("style","color:black");
 });
 $("#anytext").blur(function(){
    if($("#anytext").val()==""){
  $("#anytext").val(anytextValue);
  $("#anytext").attr("style","color:#D5D5D5");
}
 });
}
//关键字查询需求
function queryAny(){
var anytext=$("#anytext").val();
if(anytext==anytextValue) anytext="";
window.location.href="<%=path %>/order/listUser.action?anytext="+anytext+"&queryMode=any";//queryMode=any关键字查询
}
//高级查询-初始化
function to_queryMore(){
 $("#userid").val("");
 $("#anytext").val("");
 showhideDivs('queryCondition');
}
//查询
function to_query(){
$("#currentPage").val("1");
to_searchorder('','');
}
function to_searchorder(torderby,torder){
var vform = document.myform;
vform.target='_self';
document.getElementById("page_orderby").value=torderby;
document.getElementById("page_order").value=torder;
vform.action= "<%=path%>/order/listUser.action?queryMode=more";//queryMode=more高级查询
vform.submit();
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

云焰

你的鼓励是我创作的最大动力。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值