簡體   English   中英

如何在單擊時禁用搜索按鈕

[英]How to Disable the search button once it is clicked

我需要在單擊后禁用搜索按鈕。 這需要附加在以下代碼中。

<form class="search-head" id="frmSearch" action="<%= resultString %>" method="get">
    <input name="q" class="<%=cssName%> search-tags" id="tags" value="q" maxlength=50 />

    <input type="hidden" name="_charset_" value="utf-8" />
    <input type="hidden" id="searchLabel" name="searchLabel" value='<%=currentStyle.get("searchLabel", "")%>' />
        <c:if test="${enableSpringerSearch eq true}">
            <button type="button" class="change-search-engine">${springerButtonLabel}</button>
        </c:if>
    <button type="submit"><fmt:message key="label_button"/></button>

任何幫助將非常感激!

您可以創建一個單獨的函數來處理它:

document.getElementById("idOfButton").onclick = function() {
    //disable
    this.disabled = true;
}

 function disableBtn() { document.getElementById("btn").disabled = true; } 
 <input type="hidden" name="_charset_" value="utf-8" /> <input type="hidden" id="searchLabel" name="searchLabel" value='<%=currentStyle.get("searchLabel", "")%>' /> <c:if test="${enableSpringerSearch eq true}"> <button id="btn" type="button" onclick="disableBtn()" class="change-search-engine">search</button> </c:if> <button type="submit" ><fmt:message key="label_button"/></button> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM