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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:24:26+00:00 2026-05-15T21:24:26+00:00

I have a table of input fields where I want to 1)change the first

  • 0

I have a table of input fields where I want to 1)change the first column from an input field to a normal td field (which works) and 2) change the name attribute of the other td fields within the row. (this is related to a previous posting Retrieve an Input fields’ name, and then change it but is a different problem).
I want this:

<tr id="row_0" class="dataRow">  
    <td><input type="text" class="tabcell" name="_0-2" value="AFB" /><td>
    <td><input type="text" class="tabcell" name="_0-3" value=7.0 /><td>
    <td><input type="text" class="tabcell" name="_0-7" value=7.6 /></td>  
    ....  
<tr id="row_1" class="dataRow">  
    <td><input type="text" class="tabcell" name="_1-2" value="TANKERS" /><td>

replaced with this:

<tr id="row_0" class="dataRow">
    <td name="resource">AFB</td>
    <td><input type="text" class="tabcell" name="AFB_0-3" value=7.0 /><td>
    <td><input type="text" class="tabcell" name="AFB_0-7" Bvalue=7.6/><td>
    ... 
<tr id="row_1" class="dataRow">
    <td name="resource">TANKERS</td>
    ... 

My jQuery code is:

function setRowLabels() {
    var row = [];
    var rowCategory = "";

    $('.dataRow').each(function(i) {
        // get the current resource abbreviation value
        rowCategory = $('td:eq(0) input', this).val();

        // replace the contents of the first column (an input field) with a td field
        $('td:eq(0)', this).replaceWith('<td name="resource">' + rowCategory + '</td>');

        var colName = "";
        // for each input field .... 
        $('input', this).each(function(j) {
            // get the current name
            currName = $('input').attr('name');
            $('input').attr('name', rowCategory + currName);
        });
    });
}  

But that is returning:

<tr id="row_0" class="dataRow">
    <td name="resource">AFB</td>
    <td><input type="text" class="tabcell" name="...TANKERSAFBAFBAFBAFBAFBAFBAFBAFB" value=7.0 /><td>
    <td><input type="text" class="tabcell" name="...TANKERSAFBAFBAFBAFBAFBAFBAFBAFB" Bvalue=7.6/><td>  

So it repeats the name/label from column 1 multiple times, plus the name/label from every other row.
Once again, any help/pointers are welcome.

Vic

  • 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-15T21:24:26+00:00Added an answer on May 15, 2026 at 9:24 pm

    Try to replace $(‘input’) with $(this) in your inner loop.

    $(‘input’) returns every input and not only the current one.

    function setRowLabels() {
        var row = [];
        var rowCategory = "";
    
        $('.dataRow').each(function(i) {
            // get the current resource abbreviation value
            rowCategory = $('td:eq(0) input', this).val();
    
            // replace the contents of the first column (an input field) with a td field
            $('td:eq(0)', this).replaceWith('<td name="resource">' + rowCategory + '</td>');
    
            var colName = "";
            // for each input field .... 
            $('input', this).each(function(j) {
                // get the current name
                currName = $(this).attr('name');
                //         ^^^^^^^^ $('input') calls every input and not only the current one.
                $(this).attr('name', rowCategory + currName);
                //^^^^
            });
        });
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table <table> <tr><td><input radio name=R1 onClick=getOtherColumnData()>first</td><td>TR1-TD2</td><td>TR1-TD3</td><td>TR1-TD4</td></tr> <tr><td><input radio name=R1 onClick=getOtherColumnData()>Second</td><td>TR2-TD2</td><td>TR2-TD3</td><td>TR2-TD4</td></tr> <tr><td><input
I have a table containing a bunch of input fields, sort of like a
I have a html element (like select box input field) in a table. Now
TABLE bcompany companyID | cName | ... I have the input field, where user
I have a table of input fields. The form will be used by inexperienced
Possible Duplicate: PHP/MySQL - Format date/time I have input field (name:day1 and varchar) to
I have a table containing many pairs of text input fields in separate columns.
I have table like this- <table class='table'> <tr> <td class=td><input type=text name=name<%=f.getId()%> value=<%=f.getName()%>/> </td>
I have a table with a CLOB field (MySQL MediumText). I want to return
In SQL Server 2005, I have a table of input coming in of successful

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.