New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Multiple inputs send via ajax
I have interesting problem in my hands, can't wrap my head how to solve it. Seeking for knowledgeable person to help.
I have this construct in HTML/Smarty and Jquery:
My task is to send multiple inputs in table as comma separated arrays to PHP like this:
[
0 => ["name", "ttl", "type", "prio", "content"],
1 => ["name", "ttl", "type", "prio", "content"],
2 => ["name", "ttl", "type", "prio", "content"],
<...>
]
Anyone knows the best approach how to resolve this? I can't even properly google this problem...
Comments
Just use the PHP associative array syntax for your form names i.e. <input name="record[ttl][]" />
Then use jQuery form serialization to send the data through.
How to separate each iteration of inputs into separate arrays in PHP?
Add an index to your for loop and then use it for input names <input name="record[<?php echo $i; ?>][ttl]" />
make them as an javascript object, then use JSON.stringify()