View Full Version : Passing value from body to head section

Len Whistler
02-26-2007, 01:41 AM
I would like to pass this php value in the body section.


To a Javascript variable in the head section.

map.setCenter(new GLatLng($row[8]), 13);

Anyone know how i can do this?

02-26-2007, 02:05 AM
does the javascript code have to be in the head, and is the code in a function that is being called from another location in the document or is it running on the fly when the page loads up?

02-26-2007, 05:14 AM
Why not just do this?

map.setCenter(new GLatLng(<?php echo $row[8]; ?>), 13);
Since the php needs to parse before it gets to the client.

02-26-2007, 03:43 PM
exactly. i was just checking to see if that variable was being set in php after the head section.

Len Whistler
02-27-2007, 12:44 AM
Ok thanks for the replies.

The javascript code is from Google (Google Maps API) to embed google maps in your site and it does work if all the code is in the <body> section, even though the Google supplied code has most of the code in the <head> section along with the GPS coordinate values.

And yes the GPS coordinate variable is set in the <body> section from my MySQL database. I have put all of the Javascript code into the <body> and it works fine.