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

  • SEARCH
  • Home
  • 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 8952735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:56:24+00:00 2026-06-15T13:56:24+00:00

I have a form that has a dynamic number of rows. Each row has

  • 0

I have a form that has a dynamic number of rows. Each row has 3 fields, a hidden id, code, and exchange.

<form id="form_in_question">
    <table>
        <tr>
            <td>0</td>
            <td>
                <input type="hidden" id="id[]" value="123" />
                <input type="input" id="code[]" value="abc" />
            </td>
            <td>
               <select id="exchange[]">
                   <!-- Options... -->
               <select>
            <td>
        <tr>
        <!-- unlimited rows... -->
    </table>
</form>

I am trying to get an object that looks like:

data: {
    "0": {
            id: "123",
            code: "abc",
            exchange: "2"
         },
    "1": {
            id: "124",
            code: "bcd",
            exchange: "4"
         }
       }

So I can pass it a JSON object via AJAX like:

$("#dialogEditor").dialog('option', 'buttons', {'Save' : function() {
/* Define variables */
var data = $("#form_in_question").serializeArray();
    $.ajax({
    url: 'ajax.codes.php',
    dataType: 'json',
    data: {
        action: "update_codes",
    entryId: entry,
    data: data
    },
                                            type: 'POST',
                                            success: function() {
    ui.showMsg("Codes Updated");
}
});

This is what the JSON looks like that I am actually passing:

data[0][name]   id[]
data[0][value]  
data[1][name]   code[]
data[1][value]  zxc
data[2][name]   exchange[]
data[2][value]  15
data[3][name]   id[]
data[3][value]  
data[4][name]   code[]
data[4][value]  BVA
data[5][name]   exchange[]
data[5][value]  5

or the raw data:
action=update_codes&ResortId=12&data%5B0%5D%5Bname%5D=id%5B%5D&data%5B0%5D%5Bvalue%5D=&data%5B1%5D%5Bname%5D=code%5B%5D&data%5B1%5D%5Bvalue%5D=zxc&data%5B2%5D%5Bname%5D=exchange%5B%5D&data%5B2%5D%5Bvalue%5D=15&data%5B3%5D%5Bname%5D=id%5B%5D&data%5B3%5D%5Bvalue%5D=&data%5B4%5D%5Bname%5D=code%5B%5D&data%5B4%5D%5Bvalue%5D=BVA&data%5B5%5D%5Bname%5D=exchange%5B%5D&data%5B5%5D%5Bvalue%5D=5

I tried a method I found on SO but it didn’t group the 3 fields together.

  • 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-06-15T13:56:25+00:00Added an answer on June 15, 2026 at 1:56 pm

    The following code should work:

    var data = [];
    var table = $("table").get()[0];
    
    for (var i=0; i<table.rows.length; i++) {
    
        var tableRow = table.rows[i];
        var rowData = {};
        var inputData = {};
    
        inputData["id"] = $("input[id^='id']", $(tableRow.cells[1])).val();
        inputData["code"] = $("input[id^='code']", $(tableRow.cells[1])).val();
        inputData["exchange"] = $("select[id^='exchange']",$(tableRow.cells[2])).val();
    
        rowData[$(tableRow.cells[0]).text()] = inputData;
    
        data.push(rowData);
    }
    
    console.log(JSON.stringify(data));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with a stage that has a dynamic number of groups
I have a form that has 8 columns and a variable number of rows
I have a form that has all the fields pulled dynamic from a database
I have a web form which has dynamic table using repeating rows. New rows
I have a form that has a section with a dynamic number of inputs,
I have a form that has 90 buttons on it, one button for each
I have an object that has a dynamic number of attributes. For example a
I have a PDF form that has 450 fields in it and I'm going
I have a form that has dynamic controls created using jQuery. I have applied
I have a form that has label values that I would like to pass

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.