Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Previous Section | Next Section

...

  1. Click the icon in the toolbar to return to the form. In the Order Items table, select the Subtotal column by clicking on the header. In the Properties panel, uncheck Enabled. The entire column is greyed out.
  2. Go back to the rules editor, create a new rule and edit it. Change the name of the rule to: Calculate Totals
  3. In the Rule area, type or copy/paste the following.  

    Code Block
    languagejavascript
    linenumberstrue
    var grandtotal = 0.0;
    for (var i = 0; i < Item.value.length; i++) {
      if (Item[i].value.length > 0 && Quantity[i].value > 0) {
        var subtotal = Price[i].value * Quantity[i].value;
        Subtotal[i].value = subtotal;
        grandtotal += subtotal;
      }
    }
    GrandTotal.value = grandtotal;
    
    var x = OrderInformationRepeat.itemRemoved;

    Now, when the user selects an item and a quantity, the subtotal for that line and the overall grand total are automatically calculated and updated. The last line triggers the rule whenever a row is deleted from the table.

 has a powerful Rules engine. You can perform many dynamic actions in your form including the examples above as well as many other actions like showing/hiding parts of the form, automatically filling in user information, making controls required or optional dynamically, connecting to back end systems and retrieving JSON to populate form controls etc. Form more information, refer to the Rules Examples documentation.

Previous Section | Next Section