How to build a Small Calculator


Using d!NK PowerPoint Plugin, you can create an interactive app using JavaScript inserted in the Computations function.


 In this example, we have created a simple calculator app for the Medicure staff to calculate the total number of patients treated for the months of January, February and March.

Under the Open Question survey field in the PowerPoint Plugin, we have created three separate fields for the user to key in, namely: January, February and March. And their respective survey labels named as jan, feb and mar to referenced as the input field variables in JavaScript.
As seen from the screenshot above, there are several input options to be keyed in based on the question’s response format, namely: Text, Allow only numbers, Date field or Display as text area. In this scenario, we have chosen Allow only numbers option, since we are keeping track of the number of patients treated. In addition, you could make the input field mandatory if the question is mandatory.
Next, we will name the result field sumResult under Calculate Result to calculate the total number of patients keyed in by the user in the three survey questions.

To calculate the total sum, we will assign the data[sumResult]to the sum of the three question response. Take note that data[variable]is used in PowerPoint Plugin to retrieve values selected in the interactive publication, as well as to set return value to be displayed on the publication.

data[sumResult] = data[jan] + data[feb] + data[mar];

We will then put this line of code under the AnyChange event tab of Computations function as shown below. At the end, click on Create.

Finally, click on the Create button on the PowerPoint Plugin to build the d!NK publication and upload the generated d!NK file on your admin.
You have just successfully created your first d!NK interactive app with a simple small calculator function!

You can download the example powerpoint here:

Have more questions? Submit a request


Powered by Zendesk