Ajuda com Tabela (Inserir e Excluir)
Fala pessoal tudo bom? estava querendo inserir e excluir linhas de uma tabela em JavaScript (pode ser com Jquery também) porem não consegui chegar no ponto que queria apenas consegui esconder e mostrar as linhas, poderia proceder a partir de um formulário? como? o que fiz é:
[codeblock]
<script>
function hideRow (rowIndex) {
var table = document.all ? document.all.aTable :
document.getElementById('aTable');
table.rows[rowIndex].style.display = 'none';
}
function showRow (rowIndex) {
var table = document.all ? document.all.aTable :
document.getElementById('aTable');
table.rows[rowIndex].style.display = '';
}
</SCRIPT>
<FORM>
<SELECT NAME="rowIndex">
<script>
for (var i = 1; i < 5; i++)
document.write('<OPTION VALUE="' + i + '">' + i);
</SCRIPT>
</SELECT>
<INPUT TYPE="button" VALUE="esconder linha" ONCLICK="hideRow(this.form.rowIndex.selectedIndex);">
<INPUT TYPE="button" VALUE="mostrar linha" ONCLICK="showRow(this.form.rowIndex.selectedIndex);">
</FORM>
<table width="100%" border="0" id="aTable">
<tr id="1">
<td>LINHA 1 </td>
<td>Produto1</td>
<td>Valor1</td>
</tr>
<tr id="2">
<td>LINHA 2 </td>
<td>Produto2</td>
<td>Valor2</td>
</tr>
<tr id="3">
<td>LINHA 3 </td>
<td>Produto3</td>
<td>Valor3</td>
</tr>
<tr id="4">
<td>LINHA 2 </td>
<td>Produto2</td>
<td>Valor2</td>
</tr>
</table>
[/codeblock]Discussão (0)
Carregando comentários...