AnsweredAssumed Answered

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

Question asked by jr204 on Mar 30, 2016
Latest reply on Jul 13, 2016 by patrickabel

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!

Outcomes