Home >Backend Development >PHP Tutorial >How to jump to the next page after PHP page output search
When the php page is output, when the search function jumps to the next page, if no processing is done, the original data output on the second page will be returned. Use js to add search conditions to the url to ensure the jump. The output on the next page is the searched data. The following is the js code
//搜索功能 $("#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; } });
Search part code
<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="请输入会员昵称或者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>
The above is the editor’s introduction to the method of jumping to the next page after outputting a search on the PHP page. I hope it will be helpful to everyone. Help, if you have any questions please leave me a message and the editor will reply to you in time. I would also like to thank you all for your support of the PHP Chinese website!
For more related articles on how to jump to the next page after outputting a search on a PHP page, please pay attention to the PHP Chinese website!