2 回答

TA贡献1806条经验 获得超8个赞
将输入的值添加到链接
<html>
<div class="search">
<form role="search" method="get" id="search">
<div>
<input type="text" value="" name="tag_search" id="tag_search" />
<input type="button" value="Cerca"
onclick="window.location.href='https://mywebsite.com/' +
document.getElementById('tag_search').value" />
</div>
</form>
</div>
</html>

TA贡献1848条经验 获得超6个赞
添加以下Javascript来帮助
<script>
function goToSearch() {
window.location.href= 'https://mywebsite.com/' + encodeURI(document.getElementById("tag_search").value)
}
</script>
那么你的 HTML 应该是这样的
<html>
<div class="search">
<form role="search" method="get" id="search">
<div>
<input type="text" value="" name="tag_search" id="tag_search" />
<input type="button" value="Cerca" onclick="goToSearch()" />
</div>
</form>
</div>
</html>
- 2 回答
- 0 关注
- 129 浏览
添加回答
举报