1. Home
  2. Computing & Technology
  3. JavaScript

Distance Calculator

1. Introduction and Sample

clr gif
Join the Discussion

Questions? Comments?

More of this Feature

Get the Code Modify the Code

If you have a travel related web site or any kind of site where your visitors are interested in distances then this distance calculator may be just the addition you are looking for to put on your site.

The following example displays the distances between a small number of cities in Europe but the script can be easily adapted to work with any locations simply by entering the names of the locations and the distance (in kilometres) between them into a multi-dimensional array. The script simply requires starting and destination cities to be selected and the distance between them will be extracted from the array and displayed.

Starting City:
Destination City:
Distance (kilometres):
Distance (Miles):

If you want to add a copy of this distance calculator to your site then the first thing you need to do is to get the HTML and Javascript.

Explore JavaScript
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. JavaScript

©2009 About.com, a part of The New York Times Company.

All rights reserved.