What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    How To Calculate Distance With A Hidden Field

    Asked by RMFP on August 07, 2015 at 06: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 

    hidden calculate distance
  • Profile Image
    JotForm Support

    Answered by Boris on August 07, 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.)

    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.

  • Profile Image

    Answered by RMFP on August 07, 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
    ...
  • Profile Image
    JotForm Support

    Answered by Boris on August 08, 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.