How To Calculate Distance With A Hidden Field

  • RMFP
    Asked on August 7, 2015 at 6:32 PM

    hi,

    I am working on a form to where I would charge delivery based on zip code. I wanted to know how to calculate a distance form X based on the zip code of the actual address fields in which he or she fills out.  That Distance would populate a hidden field which I can then use if statements to calculate my shipping charge. However, I just do not know how to really get that first part?

     

    Thanks

    Brad 

  • Boris
    Replied on August 7, 2015 at 11:07 PM

    Brad, please take a look at our Driving_Distance widget, to see if it will satisfy your needs. Please take a look at our manual on How to Add a Widget to your Form.

    Unfortunately, there is no way to pass the address value automatically to this widget, so your users will enter their ZIP code twice - once in the Destination city field of this widget, and again on the form itself.

    It seems that Driving Distance widget doesn't always properly update its height, so you may need to inject some custom CSS to make sure that it is not being cut off for your users. On a cloned version of your form, I have used this code in my particular case:

    #customFieldFrame_35 {
      height : auto !important;
    }

    You can see the form here:

    http://form.jotformpro.com/form/52188752071962

    (It can also be cloned into your own account for a closer look into how it was set up.)

    How To Calculate Distance With A Hidden Field  Image 1 Screenshot 20

    You can use that Driving Distance field in your Form Calculations, or in your Conditional Logic (to Update a form field value). After using this distance to calculate your price, you can simply pass a calculation to a payment field.

    I hope this helps.

  • RMFP
    Replied on August 7, 2015 at 11:29 PM
    I don't think that will work it looks cheesey and i want a clean professional solution. Is there anything else we can do?
    Happy Connecting. Sent from my Sprint Samsung Galaxy S® 5 Sport
    ...
  • Boris
    Replied on August 8, 2015 at 12:53 AM

    I am sorry, but we do not have any other means available to calculate distances based on ZIP codes at this time, and then using it for calculation of a delivery cost.

    The only way currently available is to use the Driving Distance widget, which will calculate a distance between two points. You can predefine your address as one point, and users will only enter their address in the widget for the distance to be calculated.

    You can then use this calculated distance further in form calculations or conditions, to manipulate and calculate a custom shipping charge. However, this method can't update the Shipping Cost that is set through the Payment Tool, which is why you are advised to calculate your price on the form directly and pass your final value/price to the Payment Tool for payment processing.

    You can alternatively download the Source Code of your form, and ask a third-party developer to implement the custom coding that will calculate distances in a way that will best suite your particular use case.

    Please let us know if we can assist you further.