You are viewing limited content. For full access, please sign in.

Question

Question

Checkbox Filled via JavaScript Not Triggering Field Rules

asked on November 16, 2022

Hello!

I have an HTML button that I created using the following HTML:

<div align="center">
<button onclick="ReportIssue()" type="button">Report an Issue</button>
</div>

When clicked, the button triggers the following JavaScript to run which checks a checkbox in a checkbox field (field 56 in the below code):

//Allows for the selection of a hidden checkbox by clicking the "Report an Issue" button
function ReportIssue() {
  $('#Field56-0').prop('checked', true);
}

Clicking the button is successfully checking the singular checkbox option in the checkbox field, but despite having a field rule that is set to show a few additional fields when that checkbox is checked, it is not showing those additional fields. Only when I manually check the checkbox NOT via JavaScript does the field rule execute properly. 

Any tricks that I'm missing here? Thank you very much in advance!!! 

0 0

Answer

SELECTED ANSWER
replied on November 17, 2022

Try adding .change() to the end, like

$('#Field56-0').prop('checked', true).change();

Most things like field rules and such are tied to the change event, which by default only fires for user actions meaning you often have to trigger it manually when changing values via code.

1 0
replied on November 17, 2022

Thank you very much, Jason! It really was that simple, lol. That did exactly what I was hoping for. I appreciate your time and assistance! Also, love the profile pic :D Have a great rest of your day!

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.