Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Shells Virtual Desktop
BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
Shells Virtual Desktop
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.

Multiple inputs send via ajax

LeviLevi Member

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:

https://pastebin.com/UiBLY7Xd

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

  • exception0x876exception0x876 Member, Host Rep, LIR
    edited January 2022

    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.

  • @exception0x876 said:
    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?

  • exception0x876exception0x876 Member, Host Rep, LIR

    Add an index to your for loop and then use it for input names <input name="record[<?php echo $i; ?>][ttl]" />

    Thanked by 1Levi
  • make them as an javascript object, then use JSON.stringify()

Sign In or Register to comment.