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;
}
}
}