I am trying to make the first cell in my dynamic table not editable but I am having no luck. According to my knowledge, this should be right but for some reason it's not working right.
var n = 1;
function addRow(tableID,column) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
for(i=0;i<column;i++){
var cell = row.insertCell(i);
var element = document.createElement("input");
element.type = "text";
element.name = n+"0"+i;
element.size = "12";
element.id = n+"0"+i;
element.value = element.id;
if(element.id == n+"00"){
element.contenteditable = "false";
element.value = "false";
//alert("false");
}
cell.appendChild(element);
}
n++;
}
Any ideas on how to do this?
n is the number of the row
I am getting "false" for value of the first cell, meaning is entering the if statement, but it's not reading the contenteditable="false"
.
Like always, any help is greatly appreciated!
Input elements don't need contenteditable
. Just use
element.disabled = true;
to disable it.