搜索功能想加入网站url参数请问应该怎么办 刚刚问说是写入表单隐藏域。。但是好像写错了 请教一下
搜索框
<form class="search-form" action="/index.php" method="get"> <input type="hidden" name="s" value="news"> <input type="hidden" name="c" value="search"> <div class="input-group"> <input type="text" class="form-control" placeholder="搜索内容..." name="keyword" > <div class="input-group-btn"> <button class="btn default" type="submit"> <i class="glyphicon glyphicon-search"></i></button> </div> </div> </form>
内容搜索
<form class="search-form">
<div class="input-group">
<input type="text" class="form-control" placeholder="搜索内容..." name="keyword" value='{$keyword}' id='search_keyword' onkeypress="if(event.keyCode==13) {dr_module_search('search_keyword');return false;}">
<div class="input-group-btn">
<button class="btn default" type="button" onclick="dr_module_search('search_keyword')"> <i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
<script>
// 这段js是用来执行搜索的
function dr_module_search(name) {
var url="{Router::search_url($params, 'keyword', 'dayruicom')}";
var value = $("#"+name).val();
if (value) {
location.href=url.replace('dayruicom', value);
} else {
$("#"+name).focus()
dr_tips(0, "输入关键字");
}
return false;
}
</script>
</form>比如说https://127.0.0.1/html/xinwen.html?111 然后通过搜索按钮后 会进入https://127.0.0.1/news/search/keyword-关键词.html?111 这个页面 然后url参数?111 不丢失
应该这样 https://127.0.0.1/news/search/keyword-关键词-name-111.html