Sitefinity script unchecking checkbox on pageload
So I have a script to check the checkbox on the contact form on page load. I take a look why it wouldn't work and I see why. When it gets to one of the script that Sitefinity automatically loads it unchecks the checkbox.
ScriptResource.axd?d=5LbqRcQsGq6my8EsU5qQI4lgoD24FSoX8CWdEgSRSJ9BLqcMnJv-uXBViv09BiftSJLenfqhzmEFw0exVyrfFInuARw4tHQ8oxInxbwa77scEvY5mPJPGi0-fsiQtJi8hAYNpF5j4vEn9F3v4cK8SDBFNWesv8-x5Uf4EC0GrU96ivUAUU1kBhatFNXTCUDv0&t=ffffffff893a8600
is the script and I don't know what the hell that is. What should I do?
Hello Dimas,
I have just replied in the ticket you have opened related to this.
I am pasting the reply from the ticket in this forum thread as well for your convenience:
As far as I can understand from the video demonstration you have dropped a Checkboxes form field control in a form and you would like all the checkboxes to be unchecked by default. If so, please note that you can open the form for edit from Content -> Forms and then you can mark the Checkboxes form field as not required and then uncheck the option selected by default. Please publish the form.
After performing this, all the checkboxes will be unchecked by default and you will not need to execute your custom javascript for unchecking it.
I have recorded a video demonstrating the steps on my side and the results. Please find the video attached to this ticket.
[quote]Hi, In our case, we want to check box checked by default on page load. We have applied JavaScript to check check-box, but it automatically unchecked after page load. We have verified it by placing alert messages in our script that Check-box is being checked, but Sitefinity is unchecking it on page load.
Thanks
[/quote]
Hello,
Try adding a small timeout and execute the check code after the built-in script has unchecked it like so:
$(document).ready(
function
()
setTimeout(
function
()
// check the checkbox
, 350)
)
Thanks for quick response and great solution - Velizar :)