• I have a form with checkbox fields (member fees) that add value to a “total cost” calculator field when checked.

    And then I have some “add another member” fields that are added with a button using jQuery, which include another set of these checkboxes for each additional member. They can also “remove member” if they choose to.

    When those fields are added or removed via jQuery, I also have it check/uncheck the member fees checkboxes. But unfortunately, it does not update the value of the “total cost” calculator field.

    This is the jQuery for one set of the additional member fields:

    // Add a Second Member and check the membership box
    jQuery( ".add_button.second" ).click(function() {
    	jQuery( ".checkbox-member2 input" ).prop( "checked", true );		
    });
    
    // Remove a Second Member and uncheck the membership box
    jQuery( ".add_button.second .remove" ).click(function() {	
    	jQuery( ".checkbox-member2 input" ).prop( "checked", false );
    });

    My calculator field is:

    [calculator member-totals Precision:2 Prefix:$ “(is_member1 * 200) + (isnot_member1 * 275) + (is_member2 * 200) + (isnot_member2 * 275) + (is_member3 * 200) + (isnot_member3 * 275) + (is_member4 * 200) + (isnot_member4 * 275)”]

    How can I get the calculator field to update, when I use jQuery to check/uncheck the checkbox fields?

Viewing 1 replies (of 1 total)
  • Thread Starter jessicatoolstudios

    (@jessicatoolstudios)

    Update: the HTML for the calculator field is:

    <input 
    type="text" 
    name="member-totals" 
    value="0" 
    class="wpcf7-form-control wpcf7-calculator wpcf7-validates-as-calculator occf7cal-total" 
    readonly="readonly" 
    prefix="$" 
    precision="2" 
    data-formulas="(is_member1 * 200) + (isnot_member1 * 275) + (is_member2 * 200) + (isnot_member2 * 275) + (is_member3 * 200) + (isnot_member3 * 275) + (is_member4 * 200) + (isnot_member4 * 275)"
    >
Viewing 1 replies (of 1 total)
  • The topic ‘How to update calculator field with a custom jquery function?’ is closed to new replies.