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.

Zip code distance calculation function

  1. tonywoest
    Member

    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.

    Kind Regards,
    Tony

    Posted 13 years ago on Wednesday May 4, 2011 | Permalink
  2. Hi Tony,

    There would be no easy way to accomplish this by default with Gravity Forms though per your example, it is technically possible.

    In regards to customizations, there are a lot of ways to skin this cat. The easiest is probably to add a bit of custom javascript which fires after a zipcode is entered. If the zipcode is valid, it would return the mileage and price (retrieved from a DB or a static array). If not valid, it would alert the users that they need to enter a valid zip.

    Posted 13 years ago on Wednesday May 4, 2011 | Permalink