2017-08-15 10 views
0

私はモーダルでAPI表示のexternフォームを持っています。私はそれが提出されたときにモーダルを閉じたいです。私はAPIから形式を変更することはできませんexternから要素IDを取得するJavascript

私のモーダル

<div id="modal"> 
    <div class="modalconent"> 
    <div class="pipedriveWebForms" data-pd-webforms="https://pipedrivewebforms.com/form/f5cd01e9418f0b683195eb0e821770181945719"> 
    </div> 
    <button id="button">Close</button> 
    </div> 
</div> 

マイスクリプト

<script type="text/javascript"> 
    window.onload = function() { 
    document.getElementById(submitButtonLoading).onclick = function() { 
     document.getElementById('modal').style.display = "none" 
    }; 
    }; 
</script> 
<script src="https://pipedrivewebforms.com/webforms.min.js"></script> 

。 Webブラウザでそれを調べると、サブミットボタンのIDはsubmitButtonです。しかし、私の関数は、このIDで動作しません。私はAPIスクリプトを使って私のモーダル作業をする方法を知らない。

+0

が 'submitButtonLoading'が定義されていますか? – Milk

答えて

0

私が見ることのできるところは、getElementById(submitButtonLoading)には引用符がありません。

<script type="text/javascript"> 
window.onload = function() { 
    document.getElementById('submitButtonLoading').onclick = function() { 
     document.getElementById('modal').style.display = "none" 
    }; 
}; 
</script> 

希望します。乾杯!レオが言ったように

0

、あなたは

document.getElementById(submitButtonLoading). 

に引用符が欠落している。しかし、それは、ID =「submitButtonLoading」を持つ要素を求めて、私はあなたが」とIDEDあなたのコードから見るようにあなたはそれを持っていませんボタン」

<button id="button">Close</button> 

に変更し、それを:

<button id="submitButtonLoading">Close</button> 
+0

私は引用符で試してみましたが、うまくいきませんでした。クローズボタンは私のテストです。結果ページにアクセスする前に強制的にフォームを完成させたいです。 –

+0

id = "submitButtonLoading"のボタンはテスト目的ですid = "button"のものか? – Vega

+0

このdocument.getElementById( 'submitButton')。onclick ..... – Vega

関連する問題