Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5981951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:01:02+00:00 2026-05-22T22:01:02+00:00

I have a form where fields get added via JavaScript. This is fairly easy

  • 0

I have a form where fields get added via JavaScript. This is fairly easy to store without a bunch of extra JS code (for deleting and reordering) by using arrayed names for fields.

<input type="text" name="product[]" />

The problem comes when I need a multi-dimensional arrayed list of form data.

order
  request_date
  product[]
  quantity[]
    warehouse1
    warehouse2
    etc...

Basically, each order has the order data, multiple products, and each product line item can be pulled from one or more warehouses. If the line item’s order quantity is 100, and the first choice warehouse only has 50 units, they will need to select a secondary warehouse to get the second 50 units from…

I am trying to get this all onto one page possibly with JS popups to select between the different warehouses.

The problem is when I try to think of a good way to send this info to the server.

I would like to use the arrayed line item info, but cannot figure out how to send the multiple warehouses per line item back to the server. Should I just do something like comma separated values in a hidden field (populated by the JS warehouse selection popup)? Is there a better way? Any suggestions appreciated. Thanks.

If it matters, the backend is PHP.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:01:02+00:00Added an answer on May 22, 2026 at 10:01 pm

    Why not use JSON? On the PHP end you’ll end up with an array of elements for the nested arrays.

    It sounds to me like you’re either unaware of JSON (and with an SO rep of 3k, I can’t believe that) or that you’re unaware that you can pass JSON back to the server.

    But for what you’re describing, that sounds like a natural and perfect fit.


    “stick that array element as an object onto the returned value”

    var returnObject = { field1: "value", field2: "value" };
    var buildArray = [];
    $(specificSelector).each(function(){
      buildArray.push($(this).data('myKey'));
    });
    returnObject.field3 = buildArray;
    
    • Note that this uses .each which is ugly and nasty. There are better ways to do this, if you want speed or cleanness. But this works.
    • Note that I have not tested this fully, this was off the top of my head, for demonstration of concept.
    • Note that I assume each object to be selected has a .data associated with it, of key 'myKey'. You could instead iter over each cell in a table, or whatever. This is how I do it, and probably leads to bloated pages anyways. But when I append a row I attach the value as an object so I can do this sort of thing faster (faster to type that is)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have asp.net form that contains fields. When I access this window, my javascript
I have a form with multiple fields that I'm validating (some with methods added
I have a form with many input fields. When I catch the submit form
I have a form that has multiple fields, and for testing purposes is there
Say you have a web form with some fields that you want to validate
I have an asp.net text form that contains numerous decimal fields that are optional.
I have a web report that uses a Django form (new forms) for fields
This is what I'm trying to do. Have one main form with all the
I have a php form and I want to display or hide certain fields
I have to fill in multiple form fields on a web page I got

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.