Ecshop模板开发(二十六):搜索功能实现
1、html
<div id="nav_mid">
<!--search start-->
<div id="search" class="">
<div class="keys f_l">
{if $searchkeywords}
{$lang.hot_search} :
{foreach from=$searchkeywords item=val}
<a href="search.php?keywords={$val|escape:url}">{$val}</a>
{/foreach}
{/if}
</div>
<form id="searchForm" name="searchForm" method="get" action="search.php" onSubmit="return checkSearchForm()" class="f_r" style="_position:relative; top:5px;">
<select name="category" id="category" class="B_input" style="width:100px;height: 35px;border:2px solid red;">
<option value="0" style="background:red;color:white;">{$lang.all_category}</option>
{$category_list}
</select>
<input name="keywords" type="text" id="keyword" value="{$search_keywords|escape}" class="B_input" style="width:350px;height: 29px;;border:2px solid red;margin-right:0px;"/>
<input name="imageField" type="submit" value="搜 索" class="" style="cursor:pointer;width:80px;height:35px;background:red;color:white;border:2px solid red;margin-left:0px;" />
<a href="search.php?act=advanced_search" style="cursor:pointer;width:80px;height:35px;color:#666;">{$lang.advanced_search}</a>
</form>
</div>
<!--search end-->
</div>
2、js
<script type="text/javascript">
{literal}
<!--
function checkSearchForm()
{
if(document.getElementById("keyword").value)
{
return true;
}
else
{
alert("{$lang.no_keywords}");
return false;
}
}
-->
{/literal}
</script>
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇: php实现比较两个字符串日期大小的方法
- 下一篇: thinkphp5使用load和use引入第三方类