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

180
Visualizações
Multiselect dropdown not working for dynamic html table creation in Jquery

I am working on creating a table in asp.net MVC and having a button at the end for adding the rows. below is the code for adding rows. In this table we have only dropdowns and 1 multiselect dropdown for which I am using the boot strap multiselect js and css files.

For the 1st row I am able to select but for the second row the multiselect is not working like when select all is clicked its not getting selected or when one value is checked its not getting highlighted.

Please let me know if any leads.

function addRows() {

            var table = document.getElementById('totaltbl');
            var rowCount = table.rows.length;
            if (rowCount == 1)
            {
                location.reload();
                return false;
            }
            var cellCount = table.rows[0].cells.length;
            var row = table.insertRow(rowCount);
            for (var m = 0; m < rowCount; m++) {
                row.setAttribute("id", "col" + m);
            }
            for (var i = 0; i <cellCount -1; i++) {
                var cell = 'cell' + i;
                cell = row.insertCell(i);
                if (i == 1) {
              
                //This cell contains the multiselect dropdown. Copying the first cell as it is and changing the id of the multiselect dropdown
                    var copycel = document.getElementById('col' + i).innerHTML;
                    cell.innerHTML = copycel;
              
                   var id= $('table td:eq(3) select').attr('id')
                    cell.setattribute("id", "customertype" + i)
                    var element = $('table tr #col' + i +'  select')
                    element.attr('id', 'customertype' + i);
                   
                 
                   var rowid = row.id
                   var Ids = rowid.replace(/\D/g, "")
  
                 
               // each row as a customertype to differentiate that we create the id and add to the CustomerType Id
                   $('#CustomerType' +Ids).multiselect();
                   $('#'+custid).multiselect({
                       includeSelectAllOption: true
                    });
                      

                }
                else {
                    var copycel = document.getElementById('col' + i).innerHTML;
                    cell.innerHTML = copycel;
                }
               
            }
           
        }
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