《PHP學(xué)習(xí):PHP頁(yè)面輸出搜索后跳轉(zhuǎn)下一頁(yè)的處理方法》要點(diǎn):
本文介紹了PHP學(xué)習(xí):PHP頁(yè)面輸出搜索后跳轉(zhuǎn)下一頁(yè)的處理方法,希望對(duì)您有用。如果有疑問(wèn),可以聯(lián)系我們。
PHP編程php頁(yè)面輸出時(shí),搜索功能在跳轉(zhuǎn)下一頁(yè)時(shí),如果不做任何處理,會(huì)返回原有是第二頁(yè)輸出的數(shù)據(jù),用js來(lái)給url加上搜索的條件,保證跳轉(zhuǎn)下一頁(yè)時(shí)輸出的是搜索到的數(shù)據(jù).以下是js代碼
PHP編程
//搜索功能
$("#search").click(function() { //通過(guò)id找到搜索的input框
var url = $(this).attr('url');
var query = $('.search-form').find('input').serialize();
query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
query = query.replace(/^&/g, '');
if (url.indexOf('?') > 0) {
url += '&' + query;
} else {
url += '?' + query;
}
window.location.href = url;
});
//回車(chē)搜索
$(".search-form").keyup(function(e) {
if (e.keyCode === 13) {
$("#search").click();
return false;
}
});
PHP編程搜索部分代碼
PHP編程
<div class="box-tools search-form" style="width:250px;">
<div class="input-group">
<input type="text" name="nickname" value="" class="form-control input-sm pull-right" style="width: 150px;" placeholder="請(qǐng)輸入會(huì)員昵稱(chēng)或者ID">
<div class="input-group-btn">
<button class="btn btn-sm btn-default" id="search" url="{:U('Membership')}"> <i class="fa fa-search"></i></button>
</div>
</div>
</div>
PHP編程以上所述是小編給大家介紹的PHP頁(yè)面輸出搜索后跳轉(zhuǎn)下一頁(yè)的處理方法,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的.在此也非常感謝大家對(duì)維易PHP網(wǎng)站的支持!
轉(zhuǎn)載請(qǐng)注明本頁(yè)網(wǎng)址:
http://www.snjht.com/jiaocheng/3156.html