[Resolvido] Adcionar e Remover input
Ola pessoal estou com o seguinte problema no meu formulario.
Eu posso Adicionar e Remover campos, so que ele funciona apenas a primeira vez.
ao criar os campos novamente e tentar remover ele nao remove mais.
segue o cod.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<script>
function add(num){
for( i=1; i < num; i++){
var item = "item"+i;
document.getElementById("add1").innerHTML += '<div id="'+item+'" style.display="block"><input type="text" name="'+item+'" id="'+item+'"><a onclick="javascript:remove(\''+item+'\');"> Remover</a><br></div>';
}
}
function remove(num)
{
alert(num);
document.getElementById(num).value = "";
document.getElementById(num).style.display="none";
}
</script>
<form action="" method="GET">
<table align="center" width="50%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<div id="menu">
<input type="text" name="qtd" onblur="javascript:add(this.value)"/>
</div>
</td>
</tr>
<tr id="add">
<td>
<div id="add1"></div><br />
<input type="submit" name="enviar" value="enviar" />
</td>
</tr>
</table>
</form>
o que esta errado ?
Discussão (4)
Carregando comentários...