• Resolved timmtrede

    (@timmtrede)


    Hi!

    I have a problem with the distance calculation. Sometimes the reply from the google API is not fast enough, so my calculations wich are based on the distance deliver a wrong solution. This happens when people are very fast in their entry and click on the submit button (very often on a mobile phone).

    Is there a way to resolve this?

    Thanks in advance!
    Timm

    https://www.ads-software.com/plugins/calculated-fields-form/

Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hi,

    The situation you describe is not very common, however there is a simple trick to solve it.

    Select the calculated field and tick the checkbox: “Required” in its attributes, and assign to it a custom class name, for example: myfield.

    Note: The class names are assigned through the attribute: “Add Css Layout Keywords”

    Now, if the equation associated to the calculated field is:

    DISTANCE(fieldname1,fieldname2,'mi','DRIVING')

    Modify it as follows:

    (function(){
    jQuery('.myfield input').val('');
    return DISTANCE(fieldname1,fieldname2,'mi','DRIVING');
    })()

    The action clears the calculated field value before estimate the distance, so, if the user tries to submit the form, it will fail because the field is required but it is empty.

    and that’s all.
    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘Time lag dynamic distance calculation’ is closed to new replies.