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

Adding a 'Select All' button to the form - need Javascript to set a choice (multiple) control

Jump to solution

Hi all,

I'm trying to create a 'Select All' button that automatically checks every option for a specific choice (multiple) control on the form

I've been attempting this for a little while now but can not get this to work.  I found a number of posts that appears to have the exact information I needed, but upon implementing the custom JS, the checkbox values never change upon pressing the button.

One (the most recent) suggestion stated I should be using the following syntax: Re: Set value in choice column

NWF$("#"+myChoices).find(":checkbox[value='External']").attr("checked","checked");

An older post recommended using either of the following lines of code: Updating a checkbox in a checkbox group on a nintex form using NWF$

NWF$('document').ready(function(){

     NWF$('#'+jsvCheckboxField).find(':checkbox[value=\'Checkbox Choice 2\']').attr('checked', 'checked');

     NWF$('#'+jsvCheckboxField).find('input[value=\'Checkbox Choice 3\']').attr('checked', 'checked');

});

Yet in every case when I try either method, the checkboxes do not update.  I placed an alert in the code to test if the function is actually being called (it is).  I just can not find how to get the checkboxes to update properly.  I have verified the javascript variable name for the choice control matches the custom JS (searchFields), and the function is set to run on client click of the 'Select All' button.

function selectAll() {

     NWF$("#" + searchFields).find(":checkbox[value='Subject Line']").attr("checked","checked");

     NWF$("#" + searchFields).find(":checkbox[value='Message Body']").attr("checked","checked");

     NWF$("#" + searchFields).find(":checkbox[value='Attachments']").attr("checked","checked");

     alert("test");

}

The alert comes up, but the 3 lines before do not appear to have accomplished anything.  It should be a very simple function really, so I'm convinced the issue is with the lines of code I'm using to update the checkboxes.

Capture.JPG

Does anyone have an idea as to what I could be missing here?

I appreciate any assistance with this frustrating issue.  Thanks!

0 Kudos
Reply
8 Replies
jr204
Nintex Newbie

Re: Adding a 'Select All' button to the form - need Javascript to set a choice (multiple) control

Jump to solution

On another post, someone else had mentioned that my code was working properly when they tried it.  I tried adding the elements t a blank form and testing again - the issue was still occurring.

If it makes a difference, we are running NF 2010 Version: 1.9.0.0.

Does anyone in a Forms 2010 environment have a similar function in their forms?   I would like to confirm if my code works in anyone else's environment, or if anyone has working code to accomplish what I need, that could be extremely useful as well.

In the meantime, I will start looking into some older postings since we aren't running the latest version.

Thanks in advance!

Reply
janeyres
Nintex Newbie

Re: Adding a 'Select All' button to the form - need Javascript to set a choice (multiple) control

Jump to solution

Hi jr204​,

The following versions of the selectAll function also worked for me, admittedly I'm using a later version.

function selectAll() {NWF$("#" + searchFields).find(":checkbox[value='Subject Line']").attr("checked",true);NWF$("#" + searchFields).find(":checkbox[value='Message Body']").attr("checked",true);NWF$("#" + searchFields).find(":checkbox[value='Attachments']").attr("checked",true);alert("test");}

function selectAll() {NWF$("#" + searchFields).find(":checkbox[value='Subject Line']").prop("checked",true);NWF$("#" + searchFields).find(":checkbox[value='Message Body']").prop("checked",true);NWF$("#" + searchFields).find(":checkbox[value='Attachments']").prop("checked",true);alert("test");}

Hope one of these works for you!

Jan

Reply
themos
Nintex Newbie

Re: Adding a 'Select All' button to the form - need Javascript to set a choice (multiple) control

Jump to solution

Hey jr204,

Not sure if you're still looking for this, but I was able to do it using the following jQuery:

RequiredChoicesList.find("input").prop("checked", true);

Reply
Automation Master
Automation Master

Re: Adding a 'Select All' button to the form - need Javascript to set a choice (multiple) control

Jump to solution

Hello jr204​ – Especially given that several others are having success with the same code you're trying... I would recommend manually retyping your JavaScript Client ID variables and/or recreating your controls to see if that's the issue.

I've run into problems at times simply because rich-text had found it's way into my variable/class names due to copy/paste.

Reply
jr204
Nintex Newbie

Re: Adding a 'Select All' button to the form - need Javascript to set a choice (multiple) control

Jump to solution

Just an FYI, we have just recently upgraded both our SharePoint farm and our Nintex Forms to 2013.

I haven't had the time to revisit this form as we're still getting over some issues from the update.

I will be sure to update once I have some time to crack open that form again.  I suspect the issues were related to me running a (significantly) older version.

Reply
Automation Master
Automation Master

Re: Adding a 'Select All' button to the form - need Javascript to set a choice (multiple) control

Jump to solution

I suspect so, but let us know if you still have trouble following the upgrade!

Reply
jr204
Nintex Newbie

Re: Adding a 'Select All' button to the form - need Javascript to set a choice (multiple) control

Jump to solution

Just an update, after upgrading to Forms 2013 the 'Select All' button I had previously tried implementing is now working properly without any additional action on my part.

Thanks again for all of your suggestions but it looks like this was most likely a bug in an older version of Forms.

View solution in original post

Reply
Automation Master
Automation Master

Re: Adding a 'Select All' button to the form - need Javascript to set a choice (multiple) control

Jump to solution

jr204​ great to hear that fixed your issue!

0 Kudos
Reply