php頁面輸出時(shí),搜索功能在跳轉(zhuǎn)下一頁時(shí),如果不做任何處理,會(huì)返回原有是第二頁輸出的數(shù)據(jù),用js來給url加上搜索的條件,保證跳轉(zhuǎn)下一頁時(shí)輸出的是搜索到的數(shù)據(jù)。以下是js代碼
//搜索功能$("#search").click(function() { //通過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;});//回車搜索$(".search-form").keyup(function(e) {if (e.keyCode === 13) {$("#search").click();return false;}});搜索部分代碼
<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ì)員昵稱或者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頁面輸出搜索后跳轉(zhuǎn)下一頁的處理方法,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)VeVb武林網(wǎng)網(wǎng)站的支持!
新聞熱點(diǎn)
疑難解答
圖片精選