classic, javascript asp google

The attached suppose to get two from/to address that already in the codes and run the google map direction and show the page on the webpage.
for some reasons, it does not do anything and want experts helps.

Thanks
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%
function queryString(name)
{
	var value = new String (Request.Form(name));
	return convertToString(value);
}
	
function convertToString(name)
{
	var value = new String (name);
    	var fieldValue = value.toLowerCase();
	if (fieldValue == "null" || 
		fieldValue == "undefined" || 
		fieldValue == "undefine" ||
		fieldValue == "object")
		return "";
   	else return value;
}

function formatPhone(phone)
{
	try {
	     var phone = new String (phone);
		 if (phone != "")
		 {
			var code = phone.substring(0, 3);
			return "(" + code + ") " + phone.substring(3, 6) + "-" + phone.substring(6); 
		 }  
	} catch (e) { return phone; }
}
  
function formatTitleCase(word)
{
    try {
	  	var word = new String (word);
	  	if (word != "")
	  	{
	  		var letter = word.substring(0, 1).toUpperCase();
			return letter + word.substring(1, word.length).toLowerCase();  
	  	}
	} catch (e) { return word; }
}


function getDestinationAddress(val)
{
	var pos = 0;	
	var address = new String (val);
        if (address.length > 10)
	{
		var pos = address.indexOf('AAA');
                return address.substring(pos + 3);
	}
	return val;
        
}

function getOriginAddress(val)
{
	var address = new String (val);
        if (address.length > 10)
	{
		var pos = address.indexOf('AAA');
                return address.substring(0, pos);
	}
return val;
}


%>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>My Google API Application</title>
     <script type="text/javascript" src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAJxYcItOgkqR8R_oLqIOOTBQBTZKV61x1v48YJEqqfLRn8l4ZShTSK_3kHakNOTnwhzJ3mFGsv0ntTw"></script>
  <script type="text/javascript">

      var map;
      var gdir;
      var geocoder = null;
      var addressMarker;


      function initialize(from, to) {
          if (GBrowserIsCompatible()) {
              map = new GMap2(document.getElementById("map_canvas"));
              gdir = new GDirections(map, document.getElementById("directions"));
              GEvent.addListener(gdir, "load", onGDirectionsLoad);
              GEvent.addListener(gdir, "error", handleErrors);
              setDirections(from, to, "en_US");
          }
      }

      function setDirections(fromAddress, toAddress, locale) {
          gdir.load("from: " + fromAddress + " to: " + toAddress,
	{ "locale": locale });
      }

      function handleErrors() {
          if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
              alert("Error code: " + gdir.getStatus().code);
          else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
              alert("Error code: " + gdir.getStatus().code);
          else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
              alert("Error code: " + gdir.getStatus().code);
          else if (gdir.getStatus().code == G_GEO_BAD_KEY)
              alert("Error code: " + gdir.getStatus().code);
          else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
              alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
          else alert("An unknown error occurred.");

      }

      function onGDirectionsLoad() { }



    </script>
  
  </head>
  <body onunload="GUnload()">
<div id="contact"> 
<div class="contactInfo">
<p><strong>Origin:</strong><span id="origin"> <%="100 Main Street"%>&nbsp;<%="Los Angeles"%>, CA&nbsp; <%="90032"%></span></p>
<p><strong>Destination:</strong><span id="destination"> <%="100 Airport Blvd"%>&nbsp;<%="Los Angeles"%>, CA&nbsp; <%="90045"%></span></p>
</div>
<%
	  
	 
%>
<div class="clear"></div>
<div id="map_canvas"></div>
<div id="direction">
<div class="clear"></div>

</div>
</div>


<script type="text/javascript">

    try {
        $(document).ready(function () {
            var points = "1000";
            var fromAddress = document.getElementById("origin").innerHTML;
            var toAddress = document.getElementById("destination").innerHTML;
            document.getElementById("origin").innerHTML = " " + points;
            initialize(fromAddress, toAddress);

           
        });

    } catch (e) { }

</script>

  </body>
 </html>

Open in new window

Webboy2008Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
sammySeltzerConnect With a Mentor Commented:
I think you confused Javascript with VBScript

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<script>
function queryString(name)
{
	var value = new String (Request.Form(name));
	return convertToString(value);
}

function convertToString(name)
{
	var value = new String (name);
    	var fieldValue = value.toLowerCase();
	if (fieldValue == "null" ||
		fieldValue == "undefined" ||
		fieldValue == "undefine" ||
		fieldValue == "object")
		return "";
   	else return value;
}

function formatPhone(phone)
{
	try {
	     var phone = new String (phone);
		 if (phone != "")
		 {
			var code = phone.substring(0, 3);
			return "(" + code + ") " + phone.substring(3, 6) + "-" + phone.substring(6);
		 }
	} catch (e) { return phone; }
}

function formatTitleCase(word)
{
    try {
	  	var word = new String (word);
	  	if (word != "")
	  	{
	  		var letter = word.substring(0, 1).toUpperCase();
			return letter + word.substring(1, word.length).toLowerCase();
	  	}
	} catch (e) { return word; }
}


function getDestinationAddress(val)
{
	var pos = 0;
	var address = new String (val);
        if (address.length > 10)
	{
		var pos = address.indexOf('AAA');
                return address.substring(pos + 3);
	}
	return val;

}

function getOriginAddress(val)
{
	var address = new String (val);
        if (address.length > 10)
	{
		var pos = address.indexOf('AAA');
                return address.substring(0, pos);
	}
return val;
}

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>My Google API Application</title>
     <script type="text/javascript" src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAJxYcItOgkqR8R_oLqIOOTBQBTZKV61x1v48YJEqqfLRn8l4ZShTSK_3kHakNOTnwhzJ3mFGsv0ntTw"></script>
  <script type="text/javascript">

      var map;
      var gdir;
      var geocoder = null;
      var addressMarker;


      function initialize(from, to) {
          if (GBrowserIsCompatible()) {
              map = new GMap2(document.getElementById("map_canvas"));
              gdir = new GDirections(map, document.getElementById("directions"));
              GEvent.addListener(gdir, "load", onGDirectionsLoad);
              GEvent.addListener(gdir, "error", handleErrors);
              setDirections(from, to, "en_US");
          }
      }

      function setDirections(fromAddress, toAddress, locale) {
          gdir.load("from: " + fromAddress + " to: " + toAddress,
	{ "locale": locale });
      }

      function handleErrors() {
          if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
              alert("Error code: " + gdir.getStatus().code);
          else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
              alert("Error code: " + gdir.getStatus().code);
          else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
              alert("Error code: " + gdir.getStatus().code);
          else if (gdir.getStatus().code == G_GEO_BAD_KEY)
              alert("Error code: " + gdir.getStatus().code);
          else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
              alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
          else alert("An unknown error occurred.");

      }

      function onGDirectionsLoad() { }



    </script>

  </head>
  <body onunload="GUnload()">
<div id="contact">
<div class="contactInfo">
<p><strong>Origin:</strong><span id="origin"> <%="100 Main Street"%>&nbsp;<%="Los Angeles"%>, CA&nbsp; <%="90032"%></span></p>
<p><strong>Destination:</strong><span id="destination"> <%="100 Airport Blvd"%>&nbsp;<%="Los Angeles"%>, CA&nbsp; <%="90045"%></span></p>
</div>
<%


%>
<div class="clear"></div>
<div id="map_canvas"></div>
<div id="direction">
<div class="clear"></div>

</div>
</div>


<script type="text/javascript">

    try {
        $(document).ready(function () {
            var points = "1000";
            var fromAddress = document.getElementById("origin").innerHTML;
            var toAddress = document.getElementById("destination").innerHTML;
            document.getElementById("origin").innerHTML = " " + points;
            initialize(fromAddress, toAddress);


        });

    } catch (e) { }

</script>

  </body>
 </html>

Open in new window

0
 
Webboy2008Author Commented:
sammySeltzer: The codes you posted does not work. It doesn't show the map and direction at all.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.