亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將搜索框中的輸入附加到按鈕鏈接中

將搜索框中的輸入附加到按鈕鏈接中

PHP
倚天杖 2023-05-26 16:01:02
我會讓這個簡短而快速。:)我正在嘗試在我的網站上實現一個按鈕,它將我重定向到我指定的 URL + 用戶正在尋找的內容。我這里有一小段代碼:<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.?/> ????????</div> ????</form> ??</div></html>這幾乎是工作。
查看完整描述

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>


查看完整回答
反對 回復 2023-05-26
?
慕勒3428872

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>


查看完整回答
反對 回復 2023-05-26
  • 2 回答
  • 0 關注
  • 154 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號