<script type="text/javascript">
/*
posted by JayJay (Grzes)
*/
var countInputs = 0;
function addInput(id)
{
var Div = document.getElementById(id);
// Utworz 4 elementy
var br = document.createElement("br");
var inputElement0 = document.createElement("input");
var inputElement = document.createElement("input");
var inputElement1 = document.createElement("input");
inputElement0.setAttribute("name","L"+countInputs);
inputElement0.setAttribute("type","text");
inputElement0.setAttribute("size","3");
inputElement.setAttribute("name","imie"+countInputs);
inputElement.setAttribute("type","text");
inputElement1.setAttribute("name","nazwis"+countInputs);
inputElement1.setAttribute("type","text");
br.setAttribute("id","br"+countInputs);
inputElement0.setAttribute("id","Lp"+countInputs);
inputElement.setAttribute("id","nazwisko"+countInputs);
inputElement1.setAttribute("id","imie"+countInputs);
// Wpisz Liczbe Porzadkowa:
inputElement0.value=countInputs;
// usuwanie elementu po kliknieciu myszka na pole INPUT
// del_inp = "nazwisko"+countInputs;
// inputElement.onclick=function(){this.parentNode.removeChild(this);};
// inputElement.onclick=function(){Div.removeChild(document.getElementById(del_inp));};
Div.appendChild(inputElement0);
Div.appendChild(inputElement);
Div.appendChild(inputElement1);
Div.appendChild(br);
//wpisz do pola input o nazwie name=licznik LP
// document.formularz.licznik.value=countInputs;
//wpisz do pola input o id=licz
document.getElementById("licz").value=countInputs;
countInputs++;
}
function removeInput(id)
{
var Div = document.getElementById(id);
countInputs--;
del_LP = "Lp"+countInputs;
del_imie = "imie"+countInputs;
del_inp = "nazwisko"+countInputs;
br_inp = "br"+countInputs;
document.formularz.licznik.value=del_inp;
Div.removeChild(document.getElementById(del_LP));
Div.removeChild(document.getElementById(del_inp));
Div.removeChild(document.getElementById(del_imie));
Div.removeChild(document.getElementById(br_inp));
}
<form name=formularz method="get" action="zapisz.php" enctype="multipart/form-data"> <input type="button" onclick="addInput('inputLayer'); return false;" value="dodaj" /> <input type="button" onclick="removeInput('inputLayer'); return false;" value="usun" /> <input type="submit" value="wyslij" /> <input type="text" id="licz" name=licznik value="" />