cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Javascript to check a checkbox on a button click

I am trying to programmatically change the value of a Yes/No column from its default of No to Yes when the user clicks a button. I am missing one piece and I'm not sure what. Appreciate any advice.

Checkbox - name is ApprovalbyDonor.

In Advanced properties | Client ID JavaScript variable name, I have jsApprovalbyDonor

Save button - In Advanced | Client click, I have ClickMe()

The form's Settings | Custom Javascript, I have
function ClickMe() {
   NWF$('#' + jsApprovalbyDonor).attr('checked',true);
   alert('hi');
}

The javascript is called when I click the save button. The 'hi' alert box does appear (at which time I can see my checkbox on the form has been checked as well). But the underlying list value associated with the checkbox - ApprovalbyDonor does not change from No to Yes on that Save click.

(Right now I have the checkbox visible but once I get this working, its visibility property will be set to false... this is why I'm not having the user just manually check the box).

0 Kudos
Reply
2 Replies
Workflow Hero

Re: Javascript to check a checkbox on a button click

I ended up going a different route. I used this suggestion -   - and went with option 1. It feels a bit cludgey but it's also easy and it works for what I am needing.

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Javascript to check a checkbox on a button click

Hi ‌,

Just one tip: if you need a hidden control on a form to be set from JS, don't hide it using the control's Appearance setting, but in stead use a Formatting rule to hide it. Why? The former will not render the control and as such it would not be available to your JS, while the second will render the control, but not show it in the browser.

Accept as Solution Reply