当前位置:首页/归档/2019

Form表单和普通按钮实现搜索跳转功能

2019-08-04 13:41:06 / 舒彬琪 / 56 浏览

form表单实现搜索跳转功能:

使用post请求实现form表单是常见的一种提交形式,可以方便的将表单数据提交到后台,在不方便使用form表单时还可以通过另一种方式进行搜索跳转,以下就是两种跳转方式的不同实现代码:

相关html代码


<form name="forminfo1" method="post" action="/Search">
      <input name="filter" type="text" class="search" placeholder="产品搜索">
      <input name="" class="btn_search" type="submit" value="">
</form>


非form表单实现搜索跳转功能

使用js操作搜索功能


<input type="text" name="keyword" id="keyword" class="search_text" placeholder="请输入关键字"/>
<button type="submit" class="btn_submit btn_search" value="" id="search" onclick="javascript:window.location.href='/news/search.html?keyword='+ document.getElementById('keyword').value"></button>
111111 的留言

1111111

Windows 7 Chrome 2019-09-10 10:44:43