Please Note: We are no longer using forums to facilitate standard support. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Include calculator value

  1. I have a site that includes a custom-built ROI calculator built on jQuery. Is is possible at all for that value (which isn't being stored anywhere) to be included in the gravity form below it?

    http://dev.andrewnorcross.com/das/forms/calculate-the-impact/

    Here is the actual calculator:

    the javascript: http://pastie.org/1197896
    the form: http://pastie.org/1197897

    Posted 4 years ago on Monday October 4, 2010 | Permalink
  2. Yep. What you'll want to do is add another jQuery snippet that fires when the Gravity Form is submitted. This is not tested/working code, but it'll look something like this:

    jQuery("#gform_6").submit(function(){
    	var roi_result = jQuery("#roi_result").text();
    	jQuery("#hidden_field_id").val(roi_result);
    });

    You'll want to create a hidden field in the Gravity Form and then replace the id of the field where I've indicated in that jQuery bit. The concept here is that when the Gravity Form is submitted, the hidden field will be populated with whatever value is in the #roi_result span (which will contain their ROI if they've completed the calculator).

    Hope that helps. :)

    Posted 4 years ago on Monday October 4, 2010 | Permalink
  3. @David makes sense. Just one question: where does that extra bit of jQuery need to go? in the ROI calc or someplace separate?

    I've added the hidden field (li#field_6_7) but am unsure of whether or not I need to add something into the settings of that field itself, or where the jQuery needs to fire.

    Posted 4 years ago on Monday October 4, 2010 | Permalink
  4. Hi Norcross, This jquery would go inside your "jQuery(document.ready(function(){}" ideally in the js code you linked for ROI calculator; doesn't matter exactly where just inside it. Let me know how it goes.

    Posted 4 years ago on Monday October 4, 2010 | Permalink
  5. @David hmm, no dice so far. Here's the updated calculator code: http://pastie.org/1199581

    Do I need to enter anything into the hidden field in the back-end of the site?

    Posted 4 years ago on Monday October 4, 2010 | Permalink
  6. After a second look, here is an even simpler solution. Remove the snippet I provided earlier and add this line:

    $("#input_6_7").val("$" + total);

    beneath this line:

    $("#roi_result").append("$" + total);

    Should look something like this: http://pastie.org/1199597

    Posted 4 years ago on Monday October 4, 2010 | Permalink
  7. BINGO! You are a gentleman and a scholar.

    Posted 4 years ago on Tuesday October 5, 2010 | Permalink

This topic has been resolved and has been closed to new replies.

Support Tickets

Open A New Support Ticket
 Open A New Priority Support Ticket *

* Developer license holders only