Forum Moderators: open

Message Too Old, No Replies

best way to send js array to a new page

         

distorto

7:46 pm on Feb 26, 2008 (gmt 0)

10+ Year Member



I have a bunch of photos. You can click on the photo to add/remove it from a list that we want to pass to the next page. So the array keys are not fixed to values. The array is updated as the user adds or deletes the names from the list.
Now I want to pass the array of users to the next page. How? I was going to pass each user via ajax to add/delete from a php session array. That seems somehow wasteful and I thought of cookies. It's not particularly sensitive info.
But then I started wondering about using some sort of json or array serialization or something.
Can someone tell me the proper way to do this?
thanks

eelixduppy

9:36 pm on Feb 26, 2008 (gmt 0)



You could pass the info to a hidden form element(s) and then have it sent to the action page that way once the form is submitted for changes. That should make some easy php manipulation, as well. Maybe you have all the values imploded in the hidden field separated by commas and then you explode it once it reaches the action page to work with the array of images from there.

AJAX would also be a reasonable solution, however, I feel like if you don't care that there is a form submission (or it doesn't matter) then implementing it without it would be Ok, too.

distorto

9:57 pm on Feb 26, 2008 (gmt 0)

10+ Year Member



That seems logical. I had a mental block happening :)
so, how about I rewrite the inner html of a hidden input each time I update the array with a comma separated list of all the array values? Is that what you meant?
I'm trying to provide a completely extensible environment, so it should be able to handle a lot of user names, but I guess that doesn't matter with posting stuff.
thanks