cancel
Showing results for 
Search instead for 
Did you mean: 
mindymac03
Nintex Newbie

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
7 Replies
mindymac03
Nintex Newbie

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
Reply
jpmhuls
Nintex Newbie

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.

Reply
Evosolutions
Nintex Newbie

Re: Javascript to check a checkbox on a button click

@mindymac03 What was the suggestion you went with? It didn't post in your comment. I am having the same issue you were having with the underlying value not changing. 

0 Kudos
Reply
mindymac03
Nintex Newbie

Re: Javascript to check a checkbox on a button click

Good question! Let me figure out which donation form this was and get back to you. Sorry I don't remember off hand.

0 Kudos
Reply
mindymac03
Nintex Newbie

Re: Javascript to check a checkbox on a button click

I am looking at the form in question. It does not have custom javascript any more. What what what was that URL supposed to be above.
0 Kudos
Reply
mindymac03
Nintex Newbie

Re: Javascript to check a checkbox on a button click

Reply
KrunalLathiya
Nintex Newbie

Re: Javascript to check a checkbox on a button click

You can use the following solution.

The easiest one is to use a button control which action is Save and Submit. In the Advanced settings of the button, you can connect it to a number column (which default value is 0) and set its value to 1. Then you can build a workflow that will be conditionally executed at the update of the item if the number column is equal to 1. In this workflow, you can then execute another workflow or directly populate the SharePoint list. This possibility is explained by Vadim Tabakman in this article: Nintex Forms - Save or Submit - Vadim Tabakman . The inconvenience of this method is that your form has to be saved and closed to start the workflow. While getting the list items, please check null value or empty value of checkboxes. If a checkbox is unchecked, it doesn't get sent, so setting it's value to 0 if it isn't checked isn't going to help - it will always return NULL. There are two ways to fix this easily: 1) Assume a NULL in the PHP params means the checkbox is unchecked.

0 Kudos
Reply