troubleshooting Question

PHP Distance Between 2 Addresses - Part 2

Avatar of beeman000
beeman000 asked on
PHPJavaScript
3 Comments1 Solution268 ViewsLast Modified:
Here is the PHP Code:

I am getting a javascript error in IE, but not firefox. This code is enclosed in a loop that for which there is a javascript error the first 2 iterations but not the third. On the third the Google Mapping call works perfectly.
echo'
		<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;sensor=false&amp;key=ABQIAAAA7krqpTmmfiYdkJ0N9Z2iHRQ54BZ5lbd6D3Bd5hI6QK4whcZT8hR98K0EfSgTxgyO9u8EA0uPSlcAkA"
            type="text/javascript"></script>
    <script type="text/javascript">
        <!--
 
        function getDistance(pointA, pointB){
                // For this example I\'ll assume pointA and pointB are freeform addresses.
                var directions = "from: "+pointA+" to: "+pointB;
 
                // Initialize the GDirections class, load the directions
                gd = new GDirections(null,null);
 
                loader = gd.load(directions, {"locale" : "en_US"});
 
                // event listener
                GEvent.addListener(gd, "load", onLoader);
 
 
        }
 
        function onLoader(){
 
                // Grab the distance between point A and point B
                var distance = gd.getDistance().meters;
					 distance = distance/1600;
                distance = roundNumber(distance, 1);
                var duration = gd.getDuration().html;
               
 
                
					 // Alert the distance string
                document.getElementById(\'row'.$rowNumber.'\').innerHTML = distance;
        			 
		  }
        -->
        </script>
		';
		echo '<script type="text/javascript">getDistance(\''.$customerAddress.'\', \''.$cleanerAddress.'\');</script>';
		echo '<td style="border-top:solid;border-top-color:#CCCCCC;">';
		echo '<div id="row'.$rowNumber.'"></div>';
		echo '</td>';
		$rowNumber = $rowNumber+1;
	}
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros