Galera o negocio é o seguinte, alguem ja tentou trabalhar com innerHTML inserindo linhas de tabela?
funcinou com alguem?
alguem tem alguma dica?
se ue utilizo div funciona a inserção, se vou p/ tabela nao funciona nem a pau.
valeu
Galera o negocio é o seguinte, alguem ja tentou trabalhar com innerHTML inserindo linhas de tabela?
funcinou com alguem?
alguem tem alguma dica?
se ue utilizo div funciona a inserção, se vou p/ tabela nao funciona nem a pau.
valeu
Cria uma table com tbody e insira os elementos tr na tbody.
Vc chegou ja a fazer isso???
ta ai o
<html>
<head>
<title>TESTE</title>
<script>
function addElement(){
tb = document.getElementById("tabela");
alert(tb.innerHTML);
tb.innerHTML += "<tr><td>t1</td><td>t2</td></tr>";
alert(tb.innerHTML);
}
</script>
</head>
<body>
<form>
<table id="tabela">
<tbody >
<tr><td>Campo1</td><td>Campo2</td></tr>
<span ></span>
</tbody>
</table>
<input type="button" name="bt" value="VAI" onClick="addElement();"/>
</form>
</body>
</html>
fiz bem simples, tentei de tudo quanto foi forma, nao vai!!
no firefox funciona, p/ que droga o pessoal internet explorer??!?!?!?!
:evil:
afamorim
Esse funciona para ambos os browsers,
[code]
TESTE
function addElement(){
var corpo = document.createElement("TBODY");
var linha = document.createElement("TR");
var coluna1 = document.createElement("TD");
var coluna2 = document.createElement("TD");
var labelColuna1 = document.createElement("span");
labelColuna1.innerHTML = "t1";
coluna1.appendChild(labelColuna1);
var labelColuna2= document.createElement("span");
labelColuna2.innerHTML = "t2";
coluna2 .appendChild(labelColuna2);
corpo.appendChild(linha)
linha.appendChild(coluna1);
linha.appendChild(coluna2);
document.getElementById("tabela").appendChild(corpo);
}
</script>
</head>
<body>
<form>
<table id="tabela">
<tbody>
<tr><td>Campo1</td><td>Campo2</td></tr>
<span ></span>
</tbody>
</table>
<input type="button" name="bt" value="VAI" onClick="addElement();"/>
</form>
[/code]