# Distance Calculator

• Joe
Asked on December 07, 2015 at 05:20 AM

Hi, I would like to know if it would be possible for a customer to enter their zip code and based on their Zip Code they enter it would calculate the distance from the zip code entered to point B, Point B (our place of business) would be the center point covering a 40 mile radius.

The form would be used to calculate the distance that we would have to travel from our business to the customers Zip Code. We have the values in a spreadsheet that shows each zip and the distance in miles with the dollar value based on the distance:

zip 12345 = 34 miles (\$25)
zip 12346 = 38 miles (\$27)
zip 12347 = 42 miles (\$32)

I can make each zip code a product with a drop down but the drop-down would be to long as there are over 280 zip codes making the drop-down not the best choice.

I was hoping that if the customer enters his zip code it would do a database look-up and return the correct mileage for that particular zip code with the dollar amount assigned to the distance with a buy now button.

• Welvin
Answered on December 07, 2015 at 08:07 AM

You can also use our Auto Complete widget: http://widgets.jotform.com/widget/autocomp. This widget will only display the options as soon as you type in it. The only downside of this is you cannot set a calculation value in the field properties as opposed to the dropdown, radio button, and check box fields.

If you want to calculate the amount, the best way would be to use a dropdown.  Here's how you can perform a calculation in the form: http://www.jotform.com/help/259-How-to-perform-calculation-in-the-form.

Here's how you can assign a calculation value: http://www.jotform.com/help/301-How-to-Assign-Calculation-Value.

Let us know if you need any further assistance.

• Joe
Answered on December 07, 2015 at 08:58 PM

I don't think this would calculate distance according to zip code entered. can I link the web site that i found this in?

• Chriistian
Answered on December 07, 2015 at 10:03 PM

Hi Joe,

Unfortunately, there is no current widget that can help you with calculating the zip code mileage/distance (customer enters his zip code it would do a database look-up and return the correct mileage for that particular zip code with the dollar amount ). As mentioned by my colleague, the best way to achieve the logic you want is to use the drop down to manually set up this logic.

Do let us know if you need further assistance.
Regards.