Please enable JavaScript to view this site.

Process Designer

Navigation: Javascript API > Practical examples

Display or hide elements depending on a checkbox

Scroll Prev Top Next More

When creating a dialog it can be useful to display or hide individual elements depending on a checkbox. For the following example we assume that the approvalCheckbox checkbox exists.  In case the checkbox is ticked, a textarea "approvalComment" should be displayed.  In case it is unticked, the textarea should be hidden.

For this create the following JavaScript function:

function approvalDisplay() {

 

      if (jr_get_value(„approvalCheckbox“) == 1) {

         jr_show(“approvalComment”);

 } else {

          jr_hide(“approvalComment”);

      }

 

}

Now add the call up of the function as an OnClick event in the checkbox properties. Enter the function as follows into the field: approvalDisplay();

This causes the function approvalDisplay to be executed every time the checkbox is ticked or unticked.  

Additionally we recommend adding the function to the OnLoad event of the dialog. This allows checking for a ticked or unticked box when the dialog is loaded and immediately hiding or displaying the element.