I have this simple form
<form>
<div class="itenspedido">
<h4>Itens do Pedido</h4>
<div id="itens">
<div class="div-bloco-form">
<label class="obrigatorio">Quantidade:</label>
<input type="text" name="$Quantidade"/>
</div>
</div>
</div>
</form>
here the form will be cloned
<script>
function adicionar() {
var itm = document.getElementById("itens").getElementsByClassName("div-bloco-form")[0];
var cln = itm.cloneNode(true);
var inputs = cln.getElementsByTagName("input");
for (i = 0; i <= inputs.length - 1; i++) {
if (inputs[i].type === "text")
inputs[i].value = "";
}
document.getElementById("itens").appendChild(cln);
}
function remover(btn) {
var div = btn.parentNode;
if (numLinhas() > 1)
div.remove();
}
function numLinhas() {
var linhas = document.getElementById("itens").getElementsByClassName("div-bloco-form");
return linhas.length;
}
</script>
Now the following question, as I will click on the button to clone the form. I would like in the end to write to the bank, all forms. I understand the logic that will be from 1 to N. However the use of for or foreach that I believe this is what I need to use I still do not know how to do. I'm a beginner, I need some help and thank you right away.