...

View Full Version : Passing PHP Variables to a JavaScript Function Multiple Times



brando56894
09-03-2011, 06:14 PM
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 (http://pastebin.com/rTfzJM16)

xelawho
09-03-2011, 06:29 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum