Jump to content

Need help passing parameter to external file


lopes_andre

Recommended Posts

Hi,

 

I have done some JavaScript code for Google Maps API, and the code works, but I need to use the JavaScript in a external file at the same time I need to send a parameter...

 

Let me show some code...

 

Here is the function that I need to send the parameter:

 

// parameter that I need to send
var direction_par;

function initialize(direction_par) { 
      if (GBrowserIsCompatible()) { 
        map = new GMap2(document.getElementById("map_canvas")); 
        map.setUIToDefault(); // adicionar os controlosao mapa ZOOM, 
etc. 


        // Create new geocoding object 
        geocoder = new GClientGeocoder(); 
        // Retrieve location information, pass it to addToMap() 
        geocoder.getLocations(direction_par, addToMap); 


        // Criar o objecto que mostra as direcções 
        gdir = new GDirections(map, document.getElementById 
("directions")); 
        GEvent.addListener(gdir, "load", onGDirectionsLoad); 
        GEvent.addListener(gdir, "error", handleErrors); 
      } 
    } 

 

 

This is where I call the script:

 

script type="text/javascript" 
src="http://localhost/acomp_www/javascript/gm_detalhe.js?direction_par=Rue de la Mad, paris, france">
</script>

 

 

And here is where the function "initialize" is called:

 

<body onload="initialize(direction_par)" onunload="GUnload()">

 

What I'am doing wrong? There is a special way to pass parameters like this one "Rue de la Mad, paris, france", whit spaces?

 

If you can help me out, please reply.

 

 

Best Regards,

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.