(myślałem, że możnaby zrobić, żeby inputy były 'hidden' i wtedy formularz automatycznie by wysyłał te dane i otrzymywał wynik, bez przycisku submit ...)
Chodzi ogólnie o to, aby wynik był bez przeładowania strony...
Z js dużo nie mam wspólnego, dlatego proszę o pomoc.
Pozdrawiam.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <meta name="robots" content="noindex,follow" /> <script type="text/javascript"> var geocoder, location1, location2, gDir; function initialize() { geocoder = new GClientGeocoder(); gDir = new GDirections(); GEvent.addListener(gDir, "load", function() { var drivingDistanceMiles = gDir.getDistance().meters / 1609.344; var drivingDistanceKilometers = gDir.getDistance().meters / 1000; document.getElementById('results').innerHTML = drivingDistanceKilometers; }); } function showLocation() { geocoder.getLocations(document.forms[0].address1.value, function (response) { if (!response || response.Status.code != 200) { alert("Sorry, we were unable to geocode 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, function (response) { if (!response || response.Status.code != 200) { alert("Sorry, we were unable to geocode 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> </head> <body onload="initialize()"> <form action="#" onsubmit="showLocation(); return true;"> <p> <input type="text" name="address1" value="Lublin" /> <input type="text" name="address2" value="Warszawa" /> <input type="submit" value="Search" /> </p> </form> <!-- Tu się wyświetlają dane --> </body> </html>