Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
Object ID in row duplicates the first row

I'm trying to add new row with different object ID. Here is the code:

 function addRows(){
            var table = document.getElementById('emptbl');
            var rowCount = table.rows.length;
            var cellCount = table.rows[0].cells.length;
            var row = table.insertRow(rowCount);

            for(var i =0; i <= cellCount; i++){
                var cell = 'cell'+i;
                cell = row.insertCell(i);
                var copycel = document.getElementById('col'+i).innerHTML;
                cell.innerHTML=copycel;
                var inp1 = cell.getElementsByClassName('select')[0];
                console.log(' test ',JSON.stringify(inp1));
                if(i > 1) {
                $('select[name="product_id0"]').attr('name', 'product_id'+ (i).toString());
                $('select[name="product_id0"]').attr('id', 'product_id'+ (i).toString());
                $('select[name="product_id0"]').attr('class', 'product_id'+ (i).toString());

                }
                if(i == 11){
                    break;
                }
            }
        }
        function deleteRows(){
            var table = document.getElementById('emptbl');
            var rowCount = table.rows.length;
            if(rowCount > '2'){
                var row = table.deleteRow(rowCount-1);
                rowCount--;
            }
            else{
                alert('There should be atleast one row');
            }
        }
        function getComboA(selectObject) {
            console.log('test');
        }

When I press the add row button, it adds a new row but the object ID duplicates the first row object ID. Is there any solutions?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!