Here is my code:

Code:
var directionDisplay;
      var directionsService = new google.maps.DirectionsService();

      function initialize() {
        document.getElementById('hide').style.display = 'none';
        document.getElementById('hide2').style.display = 'none';
        directionsDisplay = new google.maps.DirectionsRenderer();
        var mapOptions = {
          zoom: 15,
          mapTypeId: google.maps.MapTypeId.ROADMAP,
          center: new google.maps.LatLng(14.588723, 120.975768),
        };
        map = new google.maps.Map(document.getElementById('map_canvas'),
            mapOptions);

        //Find From location    
    var fromText = document.getElementById('start');
    var fromAuto = new google.maps.places.Autocomplete(fromText);
    fromAuto.bindTo('bounds', map);
    //Find To location
    var toText = document.getElementById('end');
    var toAuto = new google.maps.places.Autocomplete(toText);
    toAuto.bindTo('bounds', map);
    //  


        directionsDisplay.setMap(map);
        directionsDisplay.setPanel(document.getElementById('directions-panel'));

        var control = document.getElementById('control');
        control.style.display = 'block';
        map.controls[google.maps.ControlPosition.TOP].push(control);
      }

      function calcRoute() {
        var start = document.getElementById('start').value;
        var end = document.getElementById('end').value;
        var request = {
          origin: start,
          destination: end,

  provideRouteAlternatives: main_route,
          travelMode: google.maps.DirectionsTravelMode.DRIVING
        };
        directionsService.route(request, function(response, status) {
          if (status == google.maps.DirectionsStatus.OK) {
            directionsDisplay.setDirections(response);
            computeTotalDistance(response);
          }
        });
      }
            function calcRoute1() {
            if (window.event.keyCode == 13){
        var start = document.getElementById('start').value;
        var end = document.getElementById('end').value;
        var request = {
          origin: start,
          destination: end,
          provideRouteAlternatives: true,
          travelMode: google.maps.DirectionsTravelMode.DRIVING

        };
        directionsService.route(request, function(response, status) {
          if (status == google.maps.DirectionsStatus.OK) {
            directionsDisplay.setDirections(response);
            computeTotalDistance(response);

          }
        });
      }}
      function computeTotalDistance(result) {

      var total = 0;
      var myroute = result.routes[0];
      for (i = 0; i < myroute.legs.length; i++) {
        total += myroute.legs[i].distance.value;

      }
I set this:

Code:
provideRouteAlternatives: true
and I get alternative routes in my directionsPanel

I can get the main route distance in this way:
Code:
var myroute = result.routes[0];
      for (i = 0; i < myroute.legs.length; i++) {
        total += myroute.legs[i].distance.value;

      }

So, I can calculate the taxi fare, for example.

But when I click on alternative routes, displayed on directionsPanel, I can't figure out how to get the new distance. So it can calculate the new fare.

I am using Google maps direction Services.

Please help!