Retirer un champs dans un formulaire après clic Bouton
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
<script>
var i = 1;
function textBoxCreateEmail(){
var y = document.createElement("INPUT");
y.setAttribute("type", "text");
y.setAttribute("Name", "email_" + i);
y.setAttribute("id", "email_" + i);
document.getElementById("new_email").appendChild(y);
var z = document.createElement("INPUT");
z.setAttribute("type", "button");
z.setAttribute("name", "emails_" + i);
z.setAttribute("id", "emails_" + i);
z.setAttribute("value", "Retirer");
document.getElementById("new_email").appendChild(z);
i++;
}
</script>
<input type="text" id="email" name="email">
<div id="new_email"></div>
<button onclick="textBoxCreateEmail()">Ajouter</button> |
Bonjour
Je souhaiterais donner la possibilité de supprimer un champs après ajout. Pour cela, j'affiche un bouton "Retirer". Seulement, je ne vois pas comment procéder pour retirer le champs et le bouton...
Quelqu'un aurait-il une piste ? 8O