unistake Posted December 20, 2015 Share Posted December 20, 2015 Hi all, I am trying to pass 4 variables from one php page to another php page containing a google maps api. The variables I am passing are geo coordinates. at the end I want to show the map on my php page however I am struggling with linking php and javascipt together. This is what I have so far: external function page: http://pastebin.com/NAKHmKxW [PART OF MAIN PHP PAGE] <div class="row"> <?php include_once("function_maps.php"); initMap($latitude, $longitude,$row['Latitude'],$row['Longitude']); ?> </div> Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted December 20, 2015 Share Posted December 20, 2015 I strongly recommend that you stop writing this PHPHTMLCSSJavaScript mishmash. It will lead to errors and cross-site scripting vulnerabilities all over the place, and you'll quickly end up with an unreadable, unmaintainable mess of spaghetti code. Keep your languages separate. Style declarations belong into external CSS files, and JavaScript code belongs into external JavaScript files. Then use Ajax to load server-provided data (like the content of PHP variables) into your JavaScript functions. Alternatively, you can embed the data into a hidden HTML element and then parse it with JavaScript. In any case: Do not echo your PHP variables directly into a JavaScript context. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.