RSS Forums RSS
Please support our JSP advertiser: Lunarpages JSP Web Hosting

Javascript array from sql query

Join Date: Jun 2005
Location: Kansas City, Missouri, USA
Posts: 344
Reputation: Troy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 4
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: Javascript array from sql query

  #4  
Jun 13th, 2005
I assume your only question is how to build your javascript line that defines the array, but instead of hard-coding the array items, you want them populated from a SQL query?

If this is the case, then this is a server-side question. And that depends on the language you are using. And this would be the wrong forum.

My suggestion is to iterate your databse recordset building a string where each time you append a comma, a single tick, the value, and another single tick. At the end of the loop, simply strip off the beginning comma. (Look at the substr command or similar in your language of choice.)

Then all you do is write your string into the javascript line as you are outputting the page.
Troy Wolf is the author of SnippetEdit. "Website editing as easy as it gets." IX Web Hosting
Reply With Quote  
All times are GMT -4. The time now is 10:13 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC