Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts

    Passing value from body to head section

    I would like to pass this php value in the body section.

    PHP Code:
    <?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?
    Leonard Whistler

  • #2
    Regular Coder
    Join Date
    Jan 2006
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Why not just do this?
    PHP Code:
    map.setCenter(new GLatLng(<?php echo $row[8]; ?>), 13);
    Since the php needs to parse before it gets to the client.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    Regular Coder
    Join Date
    Jan 2006
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts
    exactly. i was just checking to see if that variable was being set in php after the head section.

  • #5
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    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.
    Last edited by Len Whistler; 02-26-2007 at 11:46 PM.
    Leonard Whistler


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •