Kodak07 Posted April 1, 2008 Share Posted April 1, 2008 I am writing an app where im using PHP to parse out a file then i need to push some of the parsed file to a javascript function (google maps javascript to be exact) PHP SECTION <?php while(!feof($file)) { $line = fgets($file); $temp = explode(" ", $line); if ($temp[0]=="latitude:") { $lat = $temp[1]; echo $lat; } if ($temp[0]=="longitude:") { $long = $temp[1]; echo $long; } } fclose($file); ?> Javascript Function function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map_canvas")); map.setCenter(new GLatLng(37.4419, -122.1419), 13); I need my php variables to replace these numbers } } Thanks for the help Link to comment https://forums.phpfreaks.com/topic/99079-sending-php-variables-to-javascript/ Share on other sites More sharing options...
MadTechie Posted April 1, 2008 Share Posted April 1, 2008 try this function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map_canvas")); map.setCenter(new GLatLng(<?php echo $lat;?>, <?php echo $long;?>), 13); I need my php variables to replace these numbers } } Link to comment https://forums.phpfreaks.com/topic/99079-sending-php-variables-to-javascript/#findComment-506965 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.