Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Então pessoal,Eu estava querendo inserir algumas linhas quando o usuario quisesse, então eu criei um teste, mas não funciona!!!Essa é a minha página:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><script> function test(){ alert(document.getElementsByName("id").length); table = document.getElementById('tab'); tr = table.insertRow(table.rows.length); td = tr.insertCell(0); ipt = document.createElement('input'); ipt.type = 'text'; ipt.name = 'id'; ipt.value = '5'; td.appendChild(ipt); alert(document.getElementsByName("id").length); }</script></head><body><table id="tab"><tbody><tr><td><input type="text" name="id" value="1"><input type="text" name="id" value="2"><input type="text" name="id" value="3"><input type="text" name="id" value="4"></td></tr><tr><td><input type="button" onClick="test();" value="Inserir" ></td></tr></tbody></table></body></html>
quando ele entra, beleza ele pega o length, certo, mas quando esta terminando a function, ele não devolve o length,mais o input inserido!!!!Ele sempre mostra o length = 4!!!!!no FF funciona assim, mas no IE, não funciona, vcs poderiam me ajudar???Obrigado
Carregando comentários...