2017-04-10 13 views
1

検索ボタンをクリックすると、検索ボタンを無効にする必要があります。これは次のコードに追加する必要があります。一度クリックすると検索ボタンを無効にする方法

<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> 

ご協力いただければ幸いです。

+0

自分で何を調べたのですか? onclickイベントを見てください。 –

答えて

0

あなたはそれを処理するために別の関数を作成することができます。

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

ありがとうございます。しかし、どのように私は上記のコードにこれを埋め込むことができます。 –

+0

「idOfButton」の代わりに、「

0

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>

+0

これは機能していません。 function disableBtn(){ document.getElementById( "btn")。無効= true; } –

関連する問題