Function creates inputs for data inclusion
By clicking add, the fields are generated correctly
The problem is that you always send # 1:
a) If you just open and click Submit;
b) even typing texts.
what it sends:
field1 = 1
field2 = 1
field3 = 1
...
How do I send the data entered in the open fields?
thank you in advance
var qtdeCampos = 0;
function addCampos() {
var objPai = document.getElementById("campoPai");
var objFilho = document.createElement("div");
objFilho.setAttribute("id","filho"+qtdeCampos);
objPai.appendChild(objFilho);
document.getElementById("filho"+qtdeCampos).innerHTML = "<input type='text' id='campo"+qtdeCampos+"' name='campo"+qtdeCampos+"' value=''>";
qtdeCampos++;
}
<!doctype html><html lang="pt-br">
<head><meta charset="UTF-8">
</head><body>
<form name="gru" method="post" action="grava.php">
<div id="campoPai"></div>
<input type="button" value="adicionar" onclick="addCampos()">
<hr><input type="submit" value="Enviar">
</form>
</body></html>