Web Analytics Made Easy -
StatCounter Passing PHP Variables to a JavaScript Function Multiple Times - CodingForum

Announcement

Collapse
No announcement yet.

Passing PHP Variables to a JavaScript Function Multiple Times

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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; Sep 3, 2011, 01:19 PM.

  • #2
    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.

    Comment

    Working...
    X
    😀
    🥰
    🤢
    😎
    😡
    👍
    👎