Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 800455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:17:40+00:00 2026-05-14T23:17:40+00:00

I am building a price/distance calculator with Google Maps API and am trying to

  • 0

I am building a price/distance calculator with Google Maps API and am trying to pass the info from the calculator to a booking form on a separate page.

My first form has 2 submit buttons – one to make the calculation, and one to submit the relevant data to the booking form. I’m stuck trying to make the 2nd button work.

Once the API calculation has been made, I get 4 values – From, To, Cost, Distance. I am trying to pass the From, To and Cost values into my booking form by clicking the second button. But I can;t seem to get it to work. I’ve tried POST and GET but I think I may have been doing something wrong with both. Any help is appreciated.

Code for API form:

<script type="text/javascript" src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAwCUxKrPl8_9WadET5dc4KxTqOwVK5HCwTKtW27PjzpqojXnJORQ2kUsdCksByD4hzcGXiOxvn6C4cw&sensor=true"></script>

<script type="text/javascript">

var geocoder = null;
var location1 = null;
var location2 = null;
var gDir = null;
var directions = null;
var total = 0;


function roundNumber(num, dec) {
    var result = Math.floor(num*Math.pow(10 ,dec))/Math.pow(10,dec);
    return result;
}

function from(form) {
    address1 = form.start.options[form.start.selectedIndex].value;
    form.address1.value=address1;
    form.address1.focus();
}

function to(form) {
    address2=form.end.options[form.end.selectedIndex].value;
    form.address2.value=address2;
    form.address2.focus();
}

function initialize() {
    var map = new GMap2(document.getElementById("map_canvas"));
    map.setCenter(new GLatLng(54.019066,-1.381531),9);
    map.setMapType(G_NORMAL_MAP);

    geocoder = new GClientGeocoder();
    gDir = new GDirections(map);

    GEvent.addListener(gDir, "load", function() {
        var drivingDistanceMiles = gDir.getDistance().meters / 1609.344;
        var drivingDistanceKilometers = gDir.getDistance().meters / 1000;
        var miles = drivingDistanceMiles.toFixed(0);
        //var cost = (((miles - 1) * 1.9) + 3.6).toFixed(2);
        var meters = gDir.getDistance().meters.toFixed(1);

        if(miles < 70){             
            var cost = miles *1.75;
        }

        if(miles > 70){
            var cost = miles *1.2;
        }


        document.getElementById('from').innerHTML = '<strong>From: </strong>' + location1.address;
        document.getElementById('to').innerHTML = '<strong>To: </strong>' + location2.address;
        document.getElementById('cost').innerHTML = '<span class="fare"><strong>Estimated Taxi FARE:</strong>' + ' £' + cost.toFixed(2) + '</span>';
        document.getElementById('miles').innerHTML = '<strong>Distance: </strong>' + miles + ' Miles';
    });
}

// start of possible values for address not recognized on google search
// values for address1
function showLocation() {
    if (document.forms[0].address1.value == "heathrow" || document.forms[0].address1.value == "Heathrow" || document.forms[0].address1.value == "heathrow airport" || document.forms[0].address1.value == "Heathrow Airport" || document.forms[0].address1.value == "London Heathrow" || document.forms[0].address1.value =="london heathrow" ) {
        (document.forms[0].address1.value = "Heathrow Airport");
    }

    if (document.forms[0].address2.value == "heathrow" || document.forms[0].address2.value == "Heathrow" || document.forms[0].address2.value == "heathrow airport" || document.forms[0].address2.value == "Heathrow Airport" || document.forms[0].address2.value == "London Heathrow" || document.forms[0].address2.value =="london heathrow" ) {
        (document.forms[0].address2.value = "Heathrow Airport");
    }

    geocoder.getLocations(document.forms[0].address1.value +  document.forms[0].uk.value ||  document.forms[0].start.value +  document.forms[0].uk.value, function (response) {
        if (!response || response.Status.code != 200) {
            alert("Sorry, we were unable to find the first address");
        } else {
            location1 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};
            geocoder.getLocations(document.forms[0].address2.value  +  document.forms[0].uk.value, function (response) {
                if (!response || response.Status.code != 200) {
                alert("Sorry, we were unable to find the second address");
                } else {
                    location2 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};
                    gDir.load('from: ' + location1.address + ' to: ' + location2.address);
                }
            });
        }
    });
}
</script>
<style>
#quote {
    font-family: Georgia, "Times New Roman", Times, serif;
}
</style>

</head>

<body style="background-color: rgb(255, 255, 255);" onUnload="GUnload()" onLoad="initialize()">

<div id="sidebar">

<!--MAPS-->

<div id="calc_top"></div>
<div id="calc_body">
<div id="calc_inside">

<span style="font-size: 16px; font-weight: bold;">Get A Quote Now</span>

<p class="disclaimer">Fares can be calculated using either Area, Exact Address or Postcode, when entering address please
include both road name and area i.e. <em>Harrogate Road, Ripon</em>. You can also select a pickup point and destination from the dropdown boxes.
</p>

<form onSubmit="showLocation(); return false;" action="#" id="booking_form">
<p>
    <select onChange="from(this.form)" name="start">
    <option selected="selected">Select a Pickup Point</option>
    <option value="Leeds Bradford Airport">Leeds Bradford Airport</option>
    <option value="Manchester Airport">Manchester Airport</option>
    <option value="Teesside International Airport">Teeside Airport</option>
    <option value="Liverpool John Lennon Airport">Liverpool Airport</option>
    <option value="East Midlands Airport">East Midlands Airport</option>
    <option value="Heathrow International Airport">Heathrow Airport</option>
    <option value="Gatwick Airport">Gatwick Airport</option>
    <option value="Stanstead Airport">Stanstead Airport</option>
    <option value="Luton International Airport">Luton Airport</option>
    </select>
</p>
<p>
    <input type="text" value="From" name="address1"><br>
</p>
<p>
    <select onChange="to(this.form)" name="end">
    <option selected="selected">Select a Destination</option>
    <option value="Leeds Bradford Airport">Leeds Bradford Airport</option>
    <option value="Manchester Airport">Manchester Airport</option>
    <option value="Teesside International Airport">Teeside Airport</option>
    <option value="Liverpool John Lennon Airport">Liverpool Airport</option>
    <option value="East Midlands Airport">East Midlands Airport</option>
    <option value="Heathrow International Airport">Heathrow Airport</option>
    <option value="Gatwick Airport">Gatwick Airport</option>
    <option value="Stanstead Airport">Stanstead Airport</option>
    <option value="Luton International Airport">Luton Airport</option>
    </select>
</p>

<input type="text" value="To" name="address2"><br>
<input type="hidden" value=" uk" name="uk">

<br>
<input type="submit" value="Get Quote">
<input type="button" value="Reset" onClick="resetpage()"><br /><br />
<input type="submit" id="CBSubmit" value="Confirm and Book" action=""/>

</p>
</form>

<p id="from"><strong>From:</strong></p>
<p id="to"><strong>To:</strong></p>
<p id="miles"><strong>Distance: </strong></p>
<p id="cost"><span class="fare"><strong>Estimated Taxi FARE:</strong></span></p>
<p id="results"></p>

<div class="style4" style="width: 500px; height: 500px; position: relative; background-color: rgb(229, 227, 223);" id="map_canvas"></div>

</div>
</div>

Code for Booking Form:

<form method="post" action="contactengine.php" id="contact_form">
<p>

<label for="Name" id="Name">Name:</label>
<input type="text" name="Name" />

<label for="Email" id="Email">Email:</label>
<input type="text" name="Email" />
<label for="tel" id="tel">Tel No:</label>
<input type="text" name="tel" /><br /><br />
<label for="from" id="from">Pickup Point:</label>
<input type="text" name="from" value="" /><br /><br />

<label for="to" id="to">Destination:</label>
<input type="text" name="to" value=""/><br />
<label for="passengers" id="passengers">No. of passengers</label>
<input type="text" name="passengers" /><br /><br />
<label for="quote" id="quote">Price of journey:</label>
<input type="text" name="quote" value="" /><br /><br />
<label for="Message" id="Message">Any other info:</label>
<textarea name="Message" rows="20" cols="40"></textarea>
<br />

Are you an account holder?<br />
<label for="account" id="yes">Yes:</label>
<input type="radio" class="radio" value="yes" name="account">

<label for="account" id="yes">No:</label>
<input type="radio" class="radio" value="no" name="account">

</p>
<small>Non-account holders will have to pay a £5 booking fee when confirming their booking</small>
<input type="submit" name="submit" value="Submit" class="submit-button" />
</p>

</form>

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:17:40+00:00Added an answer on May 14, 2026 at 11:17 pm

    you could use

    <form onSubmit="return false;" action="booking_form.php" id="booking_form">
    

    then submits:

    <input type="submit" value="Get Quote" onclick="return showLocation();">
    <input type="button" value="Reset" onClick="resetpage()">
    <input type="submit" id="CBSubmit" value="Confirm and Book" onclick="this.form.submit();">
    

    it’s simple and efficient

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a price estimator form, which uses jQuery to manipulate select menus. Basically,
i trying to pass parameter from one site to the next site and use
I am building the fragment string in javascript from a form and setting with
I'm building some statistics and would like to have the statistics from google play
I'm building a portal that lists certain products and automatically gets the prices from
Building a new ASP.net application, and planning to separate DB, 'service' tier and Web/UI
I'm creating a custom computer building but I'm struggling to update the total price.
The page I am building should display a list of items. Let's say these
I'm building a small specialized search engine for prise info. The engine will only
I am building an online hotel booking system.... Using php and mysql.... Users can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.