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 6584653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:33:49+00:00 2026-05-25T16:33:49+00:00

I have a table with several rows containing several cells of form inputs (see

  • 0

I have a table with several rows containing several cells of form inputs (see HTML snippet below). I have a function that removes and individual rows and I’m trying to reindex all of those that remain by iterating over each row (to get the new row index) and, within that, iterating over each input ($('td input', $row).each( ... )) and updating the name and id attributes. What I’m finding is that the inputs in the first cell get reindexed, but not the cost input in the second cell.

Any idea what I’m missing that’s keeping that second cell from getting updated?

Thanks.

HTML Snippet:

<tbody>
  <tr>
    <td>
      <input type="hidden" name="data[Ticket][0][id]" value="" id="Ticket0Id">       
      <input type="hidden" name="data[Ticket][0][date_id]" value="" id="Ticket0DateId">            
      <input name="data[Ticket][0][name]" type="text" maxlength="45" value="" id="Ticket0Name">          
    </td>
    <td>
      <input name="data[Ticket][0][cost]" type="text" value="" id="Ticket0Cost">         
    </td>
  </tr>
  <tr>
    <td>
      <input type="hidden" name="data[Ticket][1][id]" value="" id="Ticket1Id">            
      <input type="hidden" name="data[Ticket][1][date_id]" value="" id="Ticket1DateId">            
      <input name="data[Ticket][1][name]" type="text" maxlength="45" value="" id="Ticket1Name">          
    </td>
    <td>
      <input name="data[Ticket][1][cost]" type="text" value="" id="Ticket1Cost">          
    </td>
  </tr>
</tbody>

By popular demand, here’s the jQuery snippet that attempts to do the reindexing:

// $tbody references the <tbody> element in the snippet above
$('tr', $tbody).each( function( i, row ) {
  var $row = $(row);

  $('td input', $row).each( function( j, input ) {
    $(input).attr( 'id', $(this).attr( 'id' ).replace( /\d+/g, i ) )
    $(input).attr( 'name', $(this).attr( 'name' ).replace( /\d+/g, i ) );
  })
});
  • 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-25T16:33:49+00:00Added an answer on May 25, 2026 at 4:33 pm

    It looks like I may have been relying too heavily on Safari’s web inspector to determine whether the attributes were being reindexed. It seems that if you have an element expanded, changes to that element are not reflected when they happen. Next time, I’ll verify with jsfiddle first (or at least second). Lesson learned.

    This one’s on me. Sorry, folks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have a table containing several hundred million rows that looks something
I have a table that contains several rows each containing one button and one
I have an html table with many rows. I'm currently grouping several rows inside
I have a table (table variable in-fact) that holds several thousand (50k approx) rows
I have an HTML Table consisting of several rows. I am trying to insert
I have an HTML table with several rows. If you hover on the row
I have a HTML table with several columns and several rows. The last row
I have a html table which has several rows - lets say 17 for
I have a table that contains several thousand rows, having a Varchar column that
I have a simple html table which has several rows. the following is implemented

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.