...

View Full Version : Passing value from body to head section



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


<?php
$row[8]
?>

To a Javascript variable in the head section.


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

Anyone know how i can do this?

JayStang
02-26-2007, 01: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?

_Aerospace_Eng_
02-26-2007, 04: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.

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

Len Whistler
02-26-2007, 11:44 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum