Adding buttons to an interactive form provides end users with a way to initiate an action, such as adding and deleting instances of subforms that define sections such as item lines in an order form.You can also add a tool tip to the delete button to display the words “Delete Item” when the user positions the pointer over the button. Using separate delete buttons is a good way to allow users to remove specific rows from the form.For example, the sample interactive Purchase Order has an Add Item button and a delete button labeled “X” for each detail subform. When the user clicks the Add Item button, a script adds an item line. Alternatively, when the user clicks one of the delete buttons, a script deletes the associated item line.The following JavaScript script in the click event of the Add Item button lets users add an item line to the sample interactive Purchase Order form. The script also recalculates the form so that the Total field includes the new line in the calculation.Because users only add item lines by using the Add Item button, the script does not need to verify the minimum count (occurrence) value.//Invoke the recalculate method to include the field values from the added subform in calculations.The following JavaScript script in the click event of the Delete button lets users use the Delete button to delete an instance of the detail subform from the sample interactive Purchase Order form. The script also recalculates the form so that the Total field no longer includes the deleted line in the calculation.Because the initial minimum occurrence value for the detail subform is 2, the script needs to reduce the minimum occurrence value to allow the person filling the form to delete the two item lines that appear automatically when the form is rendered. This script has been added to the initialize event of the detail subform.Because the form allows users to delete all instances of the detail subform, the script for the calculate event of the Total field (numTotal) needs to verify that at least one instance of the numAmount field in the detail subform exists. Otherwise, an error will appear because the calculation cannot find any occurrences of the numAmount field. This script has been added to the Calculate event of the numTotal field.