cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Workflow Hero

Setting a choice option value based on a checkbox value (NINTEX Forms)

Jump to solution

Hi all,

I want to set a choice option value based on a checkbox value:

Checked = Yes option

Not checked = No option

1. I guess this is only possible via JavaScript?!

2. If so, is there anbody able to help me with the JS code?

Thanks in advance

Michael

Labels: (2)
0 Kudos
Reply
14 Replies
Workflow Hero

Re: Setting a choice option value based on a checkbox value (NINTEX Forms)

Jump to solution

try to use a search you will definitely find a proper solution

https://community.nintex.com/search.jspa?q=choice+and+javascript 

Reply
Workflow Hero

Re: Setting a choice option value based on a checkbox value (NINTEX Forms)

Jump to solution

Search guided me to the following thread:

How to set value in Choice field based on value of other choice field 

Following the instructions there I did the following:

1. Set JavaScript variables for Checkbox and Dropdownlist:

2. Edit and copy JavaScript into Settings / custom javascript:

NWF.FormFiller.Events.RegisterAfterReady(function () {
   NWF$('#'+varcheckboxYes).change(function(){
     if (NWF$('#'+varcheckboxYes+ ' input:checked').val() == 'Yes'){
        NWF$('#'+vardropdown).val('Yes');
     }
   });
});

Unfortunately this still does not work.

0 Kudos
Reply
Workflow Hero

Re: Setting a choice option value based on a checkbox value (NINTEX Forms)

Jump to solution

input:checked selector works for radio button but not for yes/no control/checkbox.

for checkbox you have to use

NWF$('#'+varcheckboxYes).prop('checked')

 

Reply
Workflow Hero

Re: Setting a choice option value based on a checkbox value (NINTEX Forms)

Jump to solution

Hi Michael,

I had a look at your question and have your fix! On the form I have a Yes/No choice field and Yes/No dropdown list connected to a column:

I ran this script in the Custom Javascript of the Form Settings and validated that it works! 

NWF$("#"+yesnocheckbox).click(function(){ 
   if(NWF$(this).prop("checked")){
       NWF$("#"+yesnochoicefield).val("Yes");
   }
   else{
       NWF$("#"+yesnochoicefield).val("No");
   }
})

Let me know if you can't get this working!

Cheers,
Scott

Reply
Workflow Hero

Re: Setting a choice option value based on a checkbox value (NINTEX Forms)

Jump to solution

Hi Scott,

First of all thanks a lot for your time.

I re-build your approach, I am able to publish it, but it won't open, neither in preview, nor live (loading endless "please wait"......)

This is what I did:

Settings checkbox:

Settings dropdown-choice list:

Custom JavaScript Settings:

I cannot detect any error.   

Best regards

Michael

Reply
Workflow Hero

Re: Setting a choice option value based on a checkbox value (NINTEX Forms)

Jump to solution

have you checked developer console for any errors?

I would suggest to stick with onchange event handler as in your former script.

onclick event handler just captures mouse clicks, so if you change checkbox status by other ways (keyboard,....) it will not fire your handler.

Reply
Workflow Hero

Re: Setting a choice option value based on a checkbox value (NINTEX Forms)

Jump to solution

I have it now:

NWF$("#"+yesnocheckbox).click(function(){ 
   if(NWF$(this).prop("checked")){
       NWF$("#"+yesnochoicefield).val("Yes");
   }
   else{
       NWF$("#"+yesnochoicefield).val("No");
   }
});

There was only a semicolon missing at the end of the script.

Thanks to all!

Reply
Not applicable

Re: Setting a choice option value based on a checkbox value (NINTEX Forms)

Jump to solution

Hi, ‌, can you click "mark correct" on the answer that solved your problem? It's helpful for people in the community as correct answers show up higher in search results. Thanks!

0 Kudos
Reply
Workflow Hero

Re: Setting a choice option value based on a checkbox value (NINTEX Forms)

Jump to solution

It Worked for me.

0 Kudos
Reply