Click here to Skip to main content
15,887,289 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
XML
function calcRoute() {
            var start = document.getElementById('start').value;
            var end = document.getElementById('end').value;


            var request = {
                origin: start,
                destination: end,

                travelMode: google.maps.TravelMode.DRIVING
            };
            directionsService.route(request, function(response, status) {
                if (status == google.maps.DirectionsStatus.OK) {
                    directionsDisplay.setDirections(response);
                    var route = response.routes[0];
                    var summaryPanel = document.getElementById('directions_panel');
                    summaryPanel.innerHTML = '';
                    // For each route, display summary information.
                    for (var i = 0; i < route.legs.length; i++) {
                        var routeSegment = i + 1;
                        summaryPanel.innerHTML += '<b>Route Segment: ' + routeSegment + '</b><br>';
                          summaryPanel.innerHTML += route.legs[i].start_address + ' to ';
                        summaryPanel.innerHTML += route.legs[i].end_address + '<br>';
                        summaryPanel.innerHTML += route.legs[i].distance.text + '<br><br>';
                    }
                }


            });
        }

        google.maps.event.addDomListener(window, 'load', initialize);




my quesion is

XML
my button event is not fired...i want to shows the get directions using two dropdown list controls using server side controls but my button event is not fired ...wht i do?


     <asp:Button ID="btnsubmit" runat="server" OnClientClick="return calcRoute();" Text="Submit" />
Posted
Updated 30-Sep-13 21:19pm
v3
Comments
Sampath Kumar Sathiya 1-Oct-13 3:19am    
Hi,

Please use developer tools (F12) in IE and check whether your script is loading properly or not?

Hey there,

Your Button is getting a PostBack right now, that could be a problem. So add
JavaScript
return false;
inside your calcRoute function in the end.

and you might wanna debug the JavaScript code to see if it is being called, you could use alerts from line to line.

Hope it helps

Azee...
 
Share this answer
 
Comments
Siva Hyderabad 1-Oct-13 3:44am    
ya..it's working...thank u so much Azee....
you if you are not doing any server side coding on click of this button what I found from your code, you can made it simple html button. Because in this case since its a server side code its making posback on button click and so not calling javascript function.
-SG
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900