I have this JS to duplicate a registration:
function duplicarCampos(){
var clone = document.getElementById('div_dados_historico').cloneNode(true);
var destino = document.getElementById('destino');
destino.appendChild (clone);
var camposClonados = clone.getElementsByTagName('input');
for(i=0; i<camposClonados.length;i++){
camposClonados[i].value = '';
}
}
function removerCampos(id){
var node1 = document.getElementById('destino');
node1.removeChild(node1.childNodes[0]);
}
and this HTML:
<div id="div_dados_historico" style="display: none;">
<h3>HISTÓRICO PROFISSIONAL</h3>
<label>Empresa</label>
<input type="text" name="empresa1[]" placeholder="Empresa" />
<label>Cargo</label>
<input type="text" name="cargo1[]" placeholder="Cargo" />
<label>Periodo</label>
<input type="text" name="periodo1[]" placeholder="Periodo" />
<label>Atividades</label>
<textarea rows="4" cols="50" name="atividades1[]" placeholder="Atividades" > </textarea>
<center><div>
<img src="<?php echo $URL ?>site/view/images/add.jpg" style="cursor: pointer;" onclick="duplicarCampos();">
<img src="<?php echo $URL ?>site/view/images/cross.jpg" style="cursor: pointer;" onclick="removerCampos(this);">
</div> </center>
</div>
<div id="destino"> </div>
But I wanted that as I was to open a "MORE", it appears company2, company3, company4 ..... n. How could I do this in JS?