We have a contact form that is taking in some session data to help agents answer potential questions as quickly as possible. I created the fields and hid them in the JS file. I created a checkbox field to allow people to opt out, and set up the conditions for end users. I then put this js into our guides code to autocheck the box. The idea is if someone unchecks the box, the fields disable.
However the form is loading as though the box is unchecked, and the script checking the box does not trigger the condition. I have to manually uncheck the box and then check it again for the conditional fields to enable. I have tried enabling the fields and firing a change event in the code and neither work. I could change the rules so they have to check an unchecked box to opt out, but I feel like that is poor design language.
window.onload = function() {
var checkbox = document.getElementById('request_custom_fields_15309688784535');
checkbox.checked = true;
};