PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. 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.

javascript value for input field ignored by pricing calculation

  1. pluto
    Member

    Hi Everyone

    I have some javascript on my gravity form which generates a value for 'kmdistance'
    It inserts this value into a gravity form input field called input_1_19 using this code.

    document.getElementById('input_1_19').value = kmdistance;

    This works. However, I now want to add pricing calculation to my form, and a product field type 'calculation' with a simple multiplication field does not work automatically - not unless I manually enter something into the distance field.

    {Distance:19} * 2

    It seems that once the value is inserted into the form field via javascript, I need to tell gravity forms to re-check the calculation. Does anyone know how to do this ?

    Regards Steven

    Posted 12 years ago on Sunday July 22, 2012 | Permalink
  2. Can you post a link to your form please?

    Posted 12 years ago on Monday July 23, 2012 | Permalink
  3. pluto
    Member

    Hi Chris

    Sorry, I hadn't thought about including a link to the form because it is locally developed and not accessible to the net.

    I don't believe this is a bug as I am using my own embedded functions to display a google map and calculate the distance between two points.

    I understand gravity forms would 'watch' for changes made to input fields and update pricing accordingly, but only when the input field is updated manually.

    Since the value is being passed transparently, I believe I that I need to invoke a function to get gravity forms to refresh without leaving from the page.

    I can call this function in my own JavaScript if there was one that you could recommend..

    If you still wanted to see the form, I can upload this somewhere, however it's a highly sensitive project do I would need to private message you the address.

    Many thanks for your help

    Regards Steven

    Posted 12 years ago on Monday July 23, 2012 | Permalink
  4. pluto
    Member

    This is now solved.

    This post helped answer my dilemma

    http://www.gravityhelp.com/forums/topic/conditional-logic-dynamically-populated-field

    Add the change event to the end e.g.:

    jQuery("#input_1_19").val(kmdistance).change();

    regards Steven

    Posted 12 years ago on Monday July 23, 2012 | Permalink
  5. Right on, glad you got it working.

    Posted 12 years ago on Monday July 23, 2012 | Permalink

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