Can somene help me create a milage script?

I am trying to create a basic javascript that shows milage between severag areas, similar to what you find on the rear road atlas.
I have tried and failed to create anything, i just think i am total useless at understanding javascript.

The basic concept is this image attached.

There would be a drop down box that lists the destinations and another with the same but would be departure.
When a person chooses example: Butte >>> Kalipsell it would show 238 and vice versa.
it seems a simple thing to do but cant get my head around it all.
Could someone create a simple script, say 3 destinations and i will fill the rest in and see if i can understand what i am doing and then ask for additional help if required?

Here’s one way to do it.


var locations = {
    'Billings': {
        'Bozeman': 143,
        'Butte': 228
    },
    'Bozeman': {
        'Billings': 143,
        'Butte': 86
    },
    'Butte': {
        'Billings': 228,
        'Bozeman': 86
    }
};
createLocations(locations, 'mileage');

You might want to break down the createLocations function in to several different ones though, such as:


function createCells(cells, type) {
    ...
}
function createTable(data) {
    ...
}
function createLocations(locations, target) {
    ...
}