/    Sign up×
Community /Pin to ProfileBookmark

Posting a Javascript Array

Hi I’m a complete noob when it comes to javascript but for what I’m doing it is required.

I’ve searched and not found the answer that I was looking for so thought I’d ask you guys.

I have created a dynamic array of cart items within a function. When ever a user adds an item to the cart the ID is passed to the array.

I need to know from within my current function how to pass the array to a new page or convert it to PHP.

Any advice would be greatly appreciated.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@FangOct 01.2007 — With a form using method [I]get[/I] for JavaScript or [I]post[/I] for php
Copy linkTweet thisAlerts:
@benrobauthorOct 01.2007 — With a form using method [I]get[/I] for JavaScript or [I]post[/I] for php[/QUOTE]

Thanks for the reply.

I can't use GET in this instance so I'll need to use post. How do i go about populating the form with the array ready to post to my new page?

Thanks
Copy linkTweet thisAlerts:
@benrobauthorOct 01.2007 — http://www.google.com/search?q=javascript+pass+array+to+php[/QUOTE]

Thanks Fang but I've tried these, I just thought someone would be able to shed a little more light on the subject.

If anyone help can help please advise. Thanks
Copy linkTweet thisAlerts:
@toicontienOct 01.2007 — You'll have to loop through the array and then create and append hidden form fields to the FORM. Then you can use JavaScript to submit the form.
Copy linkTweet thisAlerts:
@WebnerdOct 01.2007 — You can serialize it but that would require some overhead. Try this reference:

http://aspn.activestate.com/ASPN/Cookbook/PHP/Recipe/414334
×

Success!

Help @benrob spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...