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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:57:58+00:00 2026-05-31T15:57:58+00:00

I am creating rows dynamically in javascript.As the controls in all rows have same

  • 0

I am creating rows dynamically in javascript.As the controls in all rows have same id, i need to assign an id to that control when it is creating.can anyone help me how to assign ID to that control
this is my code

function AddNewRow(tblrowdetails) {
    var table  =   $("tblrowdetails"); //getting the table id
    var rowCount = table.rows.length; 
        var row = table.insertRow(rowCount);

        var colCount = table.rows[0].cells.length;

        for(var i=0; i<colCount; i++) {

            var newcell = row.insertCell(i);
            newcell.innerHTML = table.rows[0].cells[i].innerHTML;

            switch(newcell.childNodes[0].type) {
                case "text":
                        newcell.childNodes[0].value = "";
                        break;
                case "checkbox":
                        newcell.childNodes[0].checked = false;
                        break;
                case "select-one":
                        newcell.childNodes[0].selectedIndex = 0;
                        break;
         }
     }
   }
}    

Where i need to assign id to the control and how to assign pls help me

  • 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-31T15:57:59+00:00Added an answer on May 31, 2026 at 3:57 pm

    One of the way could be

    ...
            for(var i=0; i<colCount; i++) {
    
                var newcell = row.insertCell(i);
                newcell.innerHTML = table.rows[0].cells[i].innerHTML;
                // assign id in the form of rX_cY - X,Y being row & column numbers
                $(newcell.childNodes[0]).attr('id', 'r' + rowCount.ToString() + '_c' + i.ToString());
    
                switch(newcell.childNodes[0].type) {
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page that is creating dynamically created rows in a table with
I have a container whose size can change. I will by dynamically creating instances
I am creating a large table dynamically using Javascript. I have realised the time
I am dynamically creating a table which I want to have clickable rows. When
In My application i need to create a table with dynamically creating Rows based
I have a dynamically created table, that has N rows and M QTableWidgetItems (that
I'm creating some 50 button dynamically. Text is getting set as followed: btn.Text=result.Rows[i]["Col1"].ToString()+"\n"+result.Rows[i]["Col2"].ToString() +"\n"+result.Rows[i]["Col3"].ToString();
I am having a table in which i`m dynamically creating and deleting rows. How
I am dynamically creating dragrids in different rows of an existing datagrid in asp.NET
I need to align rows in different tables that are layed out horizontally. I'd

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.