JavaScript to \select all\" and \"clear all\" for only one field."

  • 7 September 2018
  • 2 replies
  • 2 views

Badge +1

Hi,

I've added the "Select all" and "Clear all" buttons in order to have that functionality on a Multiselect multi choice field.

The code I have for both is:

Clear all

NWF$('input:checkbox').not(this).prop('checked', this.checked);


Select all

NWF$('input:checkbox').not(this).prop('checked', true);

Which is working fine. However If I add another field like that it affects all multichoice fields... How can I change this code in order to affect only one particular multichoice field?

Checking on the source code of this form I got this data from this particular Multichoice field:

<div data-UniqueId="c0a89c70-0781-4bd4-8623-f73675005e02" data-ControlName="Activity" class=" nf-filler-control nf-filler-highlightonvalidationerror  nf-resizable nf-resizable" FormControlId="e1d46371-c4a5-4f09-a77a-c0128ce1f206" data-multiselectcontrol="True" style="overflow:visible;height:85px;width:830px;top:705px;left:0px;z-index:100;background-color:;" data-controlid="e1d46371-c4a5-4f09-a77a-c0128ce1f206" data-formcontroltypeid="c0a89c70-0781-4bd4-8623-f73675005e02" data-enabled="True">

Thanks!


2 replies

Userlevel 4
Badge +11

you can add a css class to your element so you can call the function like 

NWF$('.yourclass input:checkbox').not(this).prop('checked', this.checked);

Giacomo

Badge +1

Many thanks Giacomo, it worked!

Reply