Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

116
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda