vote up 1 vote down star

I have been trying to figure this out for awhile. I have a multidimensional array in JavaScript that is 12 columns wide and an unknown number of rows like so

/*
[
    [userID (int), name, username, email, password, other 1, other 2, other 3, other 4, other 5, other 6, admin(int)],
    [userID (int), name, username, email, password, other 1, other 2, other 3, other 4, other 5, other 6, admin(int)],
    [userID (int), name, username, email, password, other 1, other 2, other 3, other 4, other 5, other 6, admin(int)],
    ...
]
*/

All the values are string except the (int) ones. This is for a real time user editing page for my site. I have the JavaScript array made now I need it so when the "Submit" button is pressed it turns the array formated like that into an PHP array and saves it as a variable. Can I get some help?

flag

2 Answers

vote up 2 vote down

Encode to JSON, post to PHP via Ajax or regular Form and decode on the serverside with json_decode

link|flag
I do not know them. :( – user275241 Feb 17 at 13:24
@user275241 them what? – Gordon Feb 17 at 13:36
1  
Nevermind, I am looking at the JSON thing... – user275241 Feb 17 at 13:41
vote up 0 vote down

What you need to do is add the data to hidden fields in your form, if they are not already regular input fields.

You probably want to use field naming like this:

<input type="hidden" name="data[100][username]" value="myusername" />
<input type="hidden" name="data[100][email]" value="[email protected]" />

Where 100 is whatever each user id is.

link|flag
It has a new user function and can be edited live. I do not see how that would work with that. – user275241 Feb 17 at 13:26
now if you can set value to innertext that would work =/ – user275241 Feb 17 at 13:40

Your Answer

Get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.