Contact Form 7 document.addEventListener

Viewed 49

I apologize first of all for my English, I use google translate.

I use Contact Form 7 and through the additional settings I would like the user after filling out the form to have access to a div contained in the same page.

The various Divs are hidden and activated via filterselection, and I use this simple command to open for example the div with ID "mydiv":

<button onclick = "filterSelection ('mydiv')">

This is the code I use for the filterSelection

<script>
filterSelection ("dashboard")
function filterSelection (c) {
  var x, i;
  x = document.getElementsByClassName ("filterDiv");
  if (c == "all") c = "dashboard";
  for (i = 0; i <x.length; i ++) {
    w3RemoveClass (x [i], "show");
    if (x [i] .className.indexOf (c)> -1) w3AddClass (x [i], "show");
  }
}

function w3AddClass (element, name) {
  var i, arr1, arr2;
  arr1 = element.className.split ("");
  arr2 = name.split ("");
  for (i = 0; i <arr2.length; i ++) {
    if (arr1.indexOf (arr2 [i]) == -1) {element.className + = "" + arr2 [i];}
  }
}

function w3RemoveClass (element, name) {
  var i, arr1, arr2;
  arr1 = element.className.split ("");
  arr2 = name.split ("");
  for (i = 0; i <arr2.length; i ++) {
    while (arr1.indexOf (arr2 [i])> -1) {
      arr1.splice (arr1.indexOf (arr2 [i]), 1);
    }
  }
  element.className = arr1.join ("");
}

// Add active class to the current button (highlight it)
var btnContainer = document.getElementById ("myBtnContainer");
var btns = btnContainer.getElementsByClassName ("btn");
for (var i = 0; i <btns.length; i ++) {
  btns [i] .addEventListener ("click", function () {
    var current = document.getElementsByClassName ("active");
    current [0] .className = current [0] .className.replace ("active", "");
    this.className + = "active";
  });
}
</script>

Contact form 7 now allows you to set additional settings via this snippet:

document.addEventListener ('wpcf7submit', function (event) {
  alert ("Fire!");
}, false);

Can someone help me to write the correct code to open for example the div with id "mydiv" after filling out the form and pressing on inva why am I going crazy?

0 Answers
Related