Hello, I have the following code:
My idea is that when calling this function insert a row in a table and to operate on it put an id to the TR, which I generate with the variable counter, the problem is that I have assigned the id ... but it does not take me value (the variable yes, but when assigning it not), if someone knows where the fault is ... Thank you!
<script>
var contador=5;
function createContact(){
contador++;
var mitabla = document.getElementById("tableContact");
var elementos = mitabla.rows.length;
var row =mitabla.insertRow(elementos);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
var cell5 = row.insertCell(4);
var cell6 = row.insertCell(5);
var cell7 = row.insertCell(6);
var cell8 = row.insertCell(7);
cell1.innerHTML = '<tr id='contador'><input type="text" size="8" name="name" id="name" size="12">';
cell2.innerHTML = '<input type="text" size="8" name="telef" id="telef" size="12">';
cell3.innerHTML = '<input type="text" size="12" name="cargo" id="cargo" size="12">';
cell4.innerHTML = '<input type="text" size="8" name="email" id="email"size="12">';
cell5.innerHTML = '<input type="checkbox" name="emailC" id="emailC" value="1">';
cell6.innerHTML = '<input type="text" size="10" name="usuario" id="usuario" size="12">';
cell7.innerHTML = '<input type="text" name="coment" id="coment" size="12">';
cell8.innerHTML = '<img onclick=modificarContacto(this); src="../graphics/edita1.jpg" height="20" width="20"><img onclick=eliminarContacto(this); src="../graphics/delete12.jpg" height="20" width="20"><img onclick=saveContact(this); src="../graphics/save123.jpg" height="20" width="20"></tr>';
}
</script>