My calculation "Total" box adds sum of all text fields whether they are visible or not, do I change

10-11  Source: Network gathering  Views:0 

I have check boxes that show and hide text fields. (Thanks to Gilads Java script). In options I have a default value for each text field.
My "Total" Field field adds all fields even if they are not checked and visible. Need to have it only include them if they are checked and visible.
You can't attach forms by email, or any other means, so it didn't come through.
Since your fields have default values and aren't calculated based on the state of the corresponding check box, you will have to use a custom calculation script for the Total field that can check to see if any of the fields are hidden, and if so, don't include their values in the sum. For example:
// Custom calculation script
(function () {
    // Set up an array of field names to include in the total
    var aFields = ["text1", "text2", "text3", text4"];
    // Initialize variables
    var i, f, sum = 0;
    // Loop through the fields an calculate the sum
    for (i = 0; i < aFields.length; i += 1) {
        // Get the current field
        f = getField(aFields[i]);
        // Add the value of the current field to the sum if the field is visible
        if (f.display == display.visible) {
            sum += +f.value;
    // Set this field value to the sum
    event.value = sum;
You can send me a PM if you want help offline.
Related articles