2 回答

TA貢獻1806條經(jīng)驗 獲得超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條經(jīng)驗 獲得超6個贊
添加以下Javascript來幫助
<script>
function goToSearch() {
window.location.href= 'https://mywebsite.com/' + encodeURI(document.getElementById("tag_search").value)
}
</script>
那么你的 HTML 應(yīng)該是這樣的
<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 關(guān)注
- 147 瀏覽
添加回答
舉報