Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

classic, javascript asp google

Posted on 2011-09-02
2
Medium Priority
?
290 Views
Last Modified: 2012-05-12
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

0
Comment
Question by:Webboy2008
2 Comments
 
LVL 29

Accepted Solution

by:
sammySeltzer earned 2000 total points
ID: 36475629
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
 

Author Comment

by:Webboy2008
ID: 36475672
sammySeltzer: The codes you posted does not work. It doesn't show the map and direction at all.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question