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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:04:20+00:00 2026-05-18T10:04:20+00:00

I want the tds (textboxes) to have unique id ‘s, so that I can

  • 0

I want the tds (textboxes) to have unique id‘s, so that I can get the values entered in those textboxes. How do I give the textboxes unique ids and get the values entered in these textboxes?

Here is my code:

<html>
<head>

<script type="text/javascript" src="jquery-1.3.2.min.js"></script>

<style type="text/css">
    div{
        padding:4px;
    }
</style>

</head>

<body>


<script type="text/javascript">

$(document).ready(
    function(){
    var counter = 2;
        $('a.add').live('click',
            function(){
                if(counter>5){
                    alert("Only 5 textboxes allowed");
                    return false;
                }   
            $(this)
                 .closest('tr')
                 .clone()
                 .appendTo('table');
            $(this)
                 .text('Remove')
                 .removeClass('add')
                 .addClass('remove');
            counter++;
            });
        $('a.remove').live('click',
            function(){
                $(this)
                    .closest('tr')
                    .remove();
                    counter--;
            });
        $('input:text').each(
            function(){
                var thisName = $(this).attr('name'),
                    thisRrow = $(this)
                                .closest('tr')
                                .index();
                //$(this).attr('name', 'row' + thisRow + thisName);
               // $(this).attr('id', 'row' + thisRow + thisName);
            });
     $("#getButtonValue").click(function () {
        var msg = '';
        for(i=1; i<counter; i++){
            msg += $('').val();
        }
              alert(msg);
        });
    });
</script>
</head><body>

<table>
    <tr>
        <th>Min Value</th>
        <th>Max Value</th>
    </tr>
    <tr>
        <td><input type="text" name="col1" id="col1" /></td>
        <td><input type="text" name="col2" id="col2" /></td>
        <td><a href="#" class="add">Add</a></td>
    </tr>
    <tr><input type='button' value='Get TextBox Value' id='getButtonValue'></tr>
</table>
</body>
</html>
  • 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-18T10:04:21+00:00Added an answer on May 18, 2026 at 10:04 am

    Use this when you create the new row…

            var newRow = 
                $(this)
                     .closest('tr')
                     .clone()
                     .appendTo('table');
            var i=1;
            $('input',newRow).each(function(){
                $(this)[0].id="Col"+counter+"_"+(i++)}
            );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get the values inside tds. I can do it by getElementsByTagName
How can I get values of TDs inside an HTML table? i.e. | ID
want to have a Hyperlink-Button in a gridView in which I can display a
I have a table, with many tds. I want to display a div behind
I have a dynamic table that I want to attach <col> elements with jQuery.
I have a table. I want to take all ninth TDs in each TR,
Here is what I want to do. In the first row that has tds
I have table that I want to remain dynamic meaning that I don't want
I have this java code and i want to return 2 values and then
I have some nested tables that I want to hide/show upon a click on

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.