You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

豆知識:プリファレンス センターのチェックボックスの動作を管理する

少しの JavaScript を使用すると、プリファレンス センターの登録解除/登録時のチェックボックスの動作を簡単に管理できることをご存知ですか?

Eloquaフォームを含むEloquaランディング・ページでホストされているサブスクリプション/プリファレンス・センターはありますか?

誰かが購読を解除するときに、購読設定のチェックを外せたらいいと思いませんか? 逆に、購読設定のいずれかをチェックしている場合は、購読解除チェックボックスをオフにしますか?

これは、Eloqua ランディング ページに Javascript を追加するだけで実現できます。


方法は次のとおりです。


ランディング ページの [設定/コードとトラッキング] セクションに移動し、[追加の Javascript] の下にある [編集] をクリックします。

以下の Javascript を追加して、「optout」値を購読解除フォーム フィールドの html 名に置き換えます。

document.addEventListener('DOMContentLoaded', function(event) {

   // Make array of all checkboxes except the unsubscribe one

   var checkboxes = document.querySelectorAll('input[type=checkbox]:not([name=optout])');

   // Loop through all checkboxes and ...

   for (i = 0; i < checkboxes.length; i++) {

       // ... give them a click trigger

       checkboxes[i].addEventListener("click", function() {

           if (this.checked == true) {

               // Uncheck unsubscribe checkbox

               document.querySelector('input[name=optout]').checked = false;

           }

       });

   }

 

   document.querySelector('input[name=optout]').onchange = function() {

       // access properties using this keyword

       if (this.checked) {

           // if checked ...

           var inputs = document.getElementsByTagName("input");

           for (index = 0; index < inputs.length; ++index) {

               if (inputs[index].type == "checkbox" && inputs[index].name != "optout") {

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!