Javascript for Selectall and Clearall on Choice control

  • 18 October 2016
  • 7 replies
  • 8 views

Badge +1

Select Checkbox(bool) should automatically select all values in choice(multiple) control. I do not want to specify individual values in choice(Multiple-selection) field control.

Individual values  it is working fine.  here is my code snippet :

NWF$('#'+Respose).find(':checkbox[value='SharePoint']').attr('checked', true);

 

 

Here is my code.

  

ControlName(Response) is my Multi-selection control ID.

 UncheckAll(ControlName){

NWF$('#'+ControlName).prop('checked',false);

}

SelectAll(ControlName){

NWF$('#'+ControlName).prop('checked',true);

}

Does any once know how to clear all  and select all items in choice field control.


7 replies

Userlevel 5
Badge +14

try following

NWF$('#'+ControlName).find(':checkbox').prop('checked',true)

choice choice control set default value multiselect  select all options  clear all options   sept2017mh

Badge +11

‌, you created this as a discussion instead of a question. I converted it to a question so users in the community would know you are looking for help.

Badge +7

Are you using a choice control with multi-selection option?

Userlevel 5
Badge +14

Hi Patti Naccarati

 

 

were you able to resolve your problem?

if so, could you select an answer that helped you and mark it 'correct answer'?

 

#BRGreview

Badge +3

Based on initial question, I tried using what was working fine for Gamar G but it is not working for me. I don't know why?

NWF$(document).ready(function () {
NWF$('#'+jsMultiChoiceTest).find(':checkbox[value='Test A']').attr('checked', true);
});‍‍‍‍‍‍‍‍‍

 Now I tried solution provided by Marian Hatala, which is also not working, makes me wonder what's wrong with it.

NWF$(document).ready(function () {
NWF$('#'+jsMultiChoiceTest).find(':checkbox').prop('checked', true);
});‍‍‍‍‍‍

here is my control:

MultiChoiceControl

Client ID

Which looks like 

221721_pastedImage_5.png

What I am trying to do is, I want to keep the all the options in one control and then based on lookup field it will select "check"some of the options automatically and "Not Applicable" will go hide.

I don't know how to say check this particular value "Test A".

I have also tried alert which is not working. It shows just blank pop-up with out any value.

NWF$('#' + jsMultiChoiceTest).click(function(){
alert(NWF$('#' + jsMultiChoiceTest).val());
});‍‍‍

If it selects "Not Applicable" all other options should go hide which is something I know how to do.

Userlevel 5
Badge +14

likely within the ready() event the control is not yet created/populated.

move your code into RegisterAfterReady() event instead.

    

The Big Event: A Closer Look At Nintex Form Events 

Badge +3

I figured out that my multi choice option's value was default coded little bit differently than other people. As you can see here with the help of Chad Davis I was able to get the value of a label.  but still trying to figure out the way to mark it as Selected.

My default value is just "on" for all the options. i.e. Test A. Test B, Test C and so on.

Reply