Far as I know, there's no way to take arrays like that and pass them straight over to js.
I've done things like this before, and the only way I did it, was to get PHP to print out the JS to define each item in the array seperatly. This is a pretty simple way of doing it, and shouldn't make too much difference to your scripting. It can still be dynamic as you like... There may be some way of putting the array into the POST_VARS and then getting JS to read it out of there, but that's just an idea, and I dunno if that'd be supported at all. chris kranz fatcuban.com -----Original Message----- From: Aidal [mailto:[EMAIL PROTECTED] Sent: 03 March 2003 14:53 To: [EMAIL PROTECTED] Subject: [PHP-WIN] PHP array to JS function ??? Hi NG. I'm having some trouble parsing a php array to a javascript function. I've searched the web and found that others before me have had the same problem, but I haven't been able to find a solution to my problem yet. simple function example: "tal" is a php array and "count" is the size of that array. The array "tal" and the var "count" has of cause been assigned values prior to calling preload_images($tal, $count); ---------------------------------- <script language=javascript> function preload_images(tal, count) { var pics = new Array(count); for (i = 0; i < count; i++) { var pic = new Image(); pic.src = 'nef/graphic/ball_' + tal[i] + '.gif'; pics[i] = pic; document.write(pic.src + '<br>'); } } </script> ---------------------------------- The idea was just to pick up the images in the new array "pics" to make sure the images were preloaded. But I added the "document.write" statement to check the value of the image path. The result is as follows for sizeof($tal) = 14: ------------------------------- http://localhost/nef/graphic/ball_undefined.gif http://localhost/nef/graphic/ball_undefined.gif http://localhost/nef/graphic/ball_undefined.gif http://localhost/nef/graphic/ball_undefined.gif http://localhost/nef/graphic/ball_undefined.gif http://localhost/nef/graphic/ball_undefined.gif http://localhost/nef/graphic/ball_undefined.gif http://localhost/nef/graphic/ball_undefined.gif http://localhost/nef/graphic/ball_undefined.gif http://localhost/nef/graphic/ball_undefined.gif http://localhost/nef/graphic/ball_undefined.gif http://localhost/nef/graphic/ball_undefined.gif http://localhost/nef/graphic/ball_undefined.gif http://localhost/nef/graphic/ball_undefined.gif -------------------------------- So my php array seems to have no values once in the javascript function. How can I fix this? Please help... /Aidal -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php