PDA

View Full Version : Best way to pass a javascript array to a php script on another page.


aluminumpork
01-16-2006, 10:46 PM
Now passing just normal variables is simple. I just construct the redirect with javascript. However, what about a Javascript array? I'm trying to figure out some way to do it right now, but am not having much luck. I'm looking to this in a dynamic fashion, so that no matter how many elements the array has, the php script will pick it up. I guess this really isn't a dedicated client side scripting issue, but meh.

Thanks!

Nevermind, I figured it out. For the good of the community, here's the way I'm doing it now.


function refreshHotelList(){
problemListString = problemList.toString();
window.location.href = "example.php?problemList=" + problemListString;
}


and then on the PHP side:



$problemList = split(",",$problemList);



So all in all very simple.