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 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2011
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Passing PHP Variables to a JavaScript Function Multiple Times

    First off I didn't know whether to post this here or in the PHP section since it deals with both, but mostly JS.

    I have a PHP scraper that scrapes the job title, company name and location from a website and stores them in separate arrays. These values are then extracted out one at a time from the array and stored into a string, that is then passed to a Google Maps API.

    I can make this successfully happen once, the thing is I need to do it multiple times. I have an idea on what I should do but don't really know how to implement it (correctly). The idea I had was to create a function in the JavaScript section that accepts three values from PHP. This function would be called in my PHP for loop that extracts the values from the array into a string. The thing that confuses me is that the Map function is called via <body onLoad="initialize()">.

    Here's the link to my code
    Last edited by brando56894; 09-03-2011 at 06:19 PM.

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,969
    Thanks
    56
    Thanked 557 Times in 554 Posts
    Quote Originally Posted by brando56894
    The thing that confuses me is that the Map function is called via <body onLoad="initialize()">.
    although I'm still not convinced that it needs to be - if you declare your lat and lng variables as global (as opposed to within the initialize function) you should be able to call the map function from anywhere.

    just a thought.


  •  

    Posting Permissions

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