lopes_andre Posted December 26, 2009 Share Posted December 26, 2009 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, Link to comment https://forums.phpfreaks.com/topic/186396-need-help-passing-parameter-to-external-file/ Share on other sites More sharing options...
rajivgonsalves Posted December 26, 2009 Share Posted December 26, 2009 I think your code should be <body onload="initialize('Rue de la Mad, paris, france')" onunload="GUnload()"> Link to comment https://forums.phpfreaks.com/topic/186396-need-help-passing-parameter-to-external-file/#findComment-984318 Share on other sites More sharing options...
lopes_andre Posted December 26, 2009 Author Share Posted December 26, 2009 Great! It is working now! Best Regards, Link to comment https://forums.phpfreaks.com/topic/186396-need-help-passing-parameter-to-external-file/#findComment-984320 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.