Skip to main content

Hello,

I have a form with a Yes/No field and a choice field with dropdown.

I want to change the value of my dropdown depending if the Yes/No field is checked or not (I do so, so that user can still force the choice manually afterward if needed).

I can not succeed to trigger my custom javascript depending if the box is checked or not.

The client ID is defined for both fields.

My method used to work for other type of fields, but not for the yes/no it seems.

for exemple, if my custom js is:

function test(){alert('hello world');}‍‍‍

if I add test() into the custom validation of the field:

  • yes/no--> js is not triggered if I check or uncheck the box
  • choice field with dropdown-->js is triggered whenever I choose one of the dropdown element

Any ideas?

Add the below script in the Form Custom Javascript section and set the Yes/No field Client ID in Javascript variable

NWF$(document).ready(function () {
//for yes/no field type
var opt= NWF$("#" + chkOption);
opt.change(function(){

//below if condition to check if is checked

//if(opt.prop('checked'))
alert("Custom message");
});
});

201458_pastedImage_3.png

201424_pastedImage_2.png


That is perfect! Thanks a lot Chaitra


Reply