set multiple field values based on other field selection


Userlevel 3
Badge +8

Hi everyone,

I added this question to an existing thread but haven't seen any traction so decided to post a new question.

I would like to set the values for five choice fields based on the selection made in a previous choice field. I can get the first field to update but haven't had any luck with the rest. Some of these choice fields allow multiple values. I'm pretty new to JS in Nintex. I've done this a ton in Adobe forms but this seems way different.

here's my JS I'm placing in the form settings.

Working:

 NWF.FormFiller.Events.RegisterAfterReady(function () {
   NWF$('#'+varBusRole).change(function(){
     if (NWF$('#'+varBusRole).val ("Yes")){
        NWF$('#'+varEnvi) .val ("Both");
     }
   });
});

Not working:

 NWF.FormFiller.Events.RegisterAfterReady(function () {
   NWF$('#'+varBusRole).change(function(){
     if (NWF$('#'+varBusRole).val ("Yes")){
        NWF$('#'+varEnvi) .val ("Both");

        NWF$('#'+varSystem) .val ("All");

        NWF$('#'+varLandscape) .val ("Training; Production");  
     }
   });
});

Thank you

Kassie


5 replies

Userlevel 3
Badge +8

Have discovered that the script works when using dropdown choice fields, but not fields that allow multiple selections. Thought I would get it to work by adding ;# between each selection. no luck.

Any ideas?

Thanks

Kassie

Edit:

I decided to just add some help text for the fields that allow multiple selections as a workaround. But, I set my rule to show this help text when the JavaScript updated the business role field, and that isn't working either. Like the form doesn't realize that the field has been updated to run the rule when it's changed by JavaScript...

I'm having a rough time with this one, even my workarounds aren't doing the trick.

Edit 2:

I've tried to add ':checked' to set the multi selection choice fields, still nothing.

Also, I wanted to add an } else { to set the values back to null in case the user changed the choice field back to something that should not populate the fields, this doesn't work.

Userlevel 5
Badge +14

to set value of a choice control rendered as 'chek boxes (multiple selection) use following script

NWF$('#'+varLandscape).find('input[value="Training"]').prop('checked',true);
NWF$('#'+varLandscape).find('input[value="Production"]').prop('checked',true);
‍‍‍‍‍‍
Userlevel 3
Badge +8

Marian, seriously, If you drink, I owe you a beer, or another type of beverage of your choosing.

Thank you so much once again! You've helped me out numerous times.

~ Kassie

Userlevel 5
Badge +14

glad I could help.

I never refuse invitation  for a good beer happy.pnghappy.pnghappy.png

Badge

that was so helpful i spent 2 days looking for this

Reply