var conacc = document.getElementsByClassName("ContractResultsAccordion"); var j; var contract_clicked = 0; function sendcontract() { liveSend({'contract_clicked': contract_clicked}) } for (j = 0; j < conacc.length; j++) { conacc[j].addEventListener("click", function() { contract_clicked = 1; //captures if people needed contract info to solve calculation sendcontract(); /* Toggle between adding and removing the "active" class, to highlight the button that controls the panel */ this.classList.toggle("active"); /* Toggle between hiding and showing the active panel */ var ContractResultsPanel = this.nextElementSibling; if (ContractResultsPanel.style.display === "block") { ContractResultsPanel.style.display = "none"; conacc[j-1].innerHTML = "To read the contract information, click here"; } else { ContractResultsPanel.style.display = "block"; conacc[j-1].innerHTML = "To hide the contract information, click here"; } }); }