New Dialog: Add a Dialog Box in Your Nintex Forms

Although Nintex Forms allows you to show/hide labels to show additional information, sometimes it's just nicer to use a dialog box. In this example, I'll show you how to pop up a dialog box when you choose a certain value from a drop down. Let's get to it!

The Build

In your SharePoint list, add a Choice column with a drop down display using the following values: 

  • Breakfast
  • Lunch 
  • Dinner

Next, we will need to grab the CDN links for jQuery to greatly reduce the amount of code we will need to write. 

In the Nintex Forms designer tab, select Settings > Advanced > Custom CSS includes and place the following link:

  • //code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css

Right below the Custom CSS includes section is the Custom JavaSctipt includes section. In the Custom JavaSctipt includes field add the following links:

  • https://code.jquery.com/jquery-1.12.4.min.js
  • https://code.jquery.com/ui/1.12.0/jquery-ui.min.js

Next we will add a Rich Text Control and get ready to add some code!

The Code

In the Rich Text control, click within the body of Rich Text field in the Control Settings modal window and then click on the 'Edit Source' button on the Format Text ribbon. Next, add the following html:

<div title="Important Meal" id="dialog-lunch-dinner">            
   <p>                        
      <span class="ui-icon ui-icon-circle-check" style="margin: 0px 7px 50px 0px; float: left;"></span>    Don&#39;t forget, breakfast is the most important meal of the day!  </p>
</div>
<div title="Lunch" id="dialog-breakfast-lunch">            
   <p>                        
      <span class="ui-icon ui-icon-circle-check" style="margin: 0px 7px 50px 0px; float: left;"></span>    Lunch is great, but don&#39;t forget to snack!  </p>
</div>

On the form designer you will see the following in your Rich Text control, but don't fret, we will hide this control with some JavaScript on form load.

Let's go back to Form Settings and select Custom JavaScript. Please paste the following JavaScript in your Custom JavaScript field:

NWF$(document).ready(function() {
 NWF$('#dialog-breakfast-lunch').css("display", "none");
 NWF$('#dialog-lunch-dinner').css('display', 'none');
 NWF$('#' + chFood).change(function(){
  var ddFood = NWF$('#' + chFood + ' option:selected').val();  
   switch (ddFood) {
    case ("Breakfast"):
    NWF$('#dialog-lunch-dinner').dialog();
    break;
    case ("Lunch"):
    NWF$('#dialog-breakfast-lunch').dialog();
    break;
   }
 });
});

Great, now let's save these settings and Save the form in the designer. Let's take a look at what we just built!

The Result

On form load, you'll notice that that Rich Text control is no longer visible.

Select 'Breakfast' from the Food choice control and you will see a new dialog box appear:

Select 'Lunch' and you will be presented with another dialog box:

Pretty cool feature with just a tiny bit of code!