0
Hi! I created an HTML form for a curriculum generator and in the field "professional experience" has only inputs to record an experience.
HTML:
<fieldset id="professional-info">
<legend><h2>Experiência profissional</h2></legend>
<div class="prof-exp">
<label for="cargo"> Cargo: <input type="text" name="cargo" id="cargo"></label><br>
<label for="empresa"> Empresa: <input type="text" name="empresa" id="empresa"></label><br>
<label for="data-inicio"> Início: <input type="date" name="data-inicio" id="data-inicio"></label>
<label for="data-fim"> Término: <input type="date" name="data-fim" id="data-fim"></label>
<label for="atual"><input type="checkbox" name="atual" id="atual">Ainda trabalho aqui</label><br>
<label for="descricao"> Descrição: <textarea name="descricao" id="descricao" cols="40" rows="1"></textarea></label>
</div>
<button type="button" form="main" id="add-exp">Adicionar outra experiência</button>
</fieldset>
JAVASCRIPT:
function addRemoveExp() {
$(".prof-exp").clone().appendTo("#professional-info");}document.getElementById("add-exp").onclick = function(){addRemoveExp()};
As you can see, I left a button to add another experience, so that the user can register new experiences if they wish.
So far I’m trying to use the methods clone()
and appendTo()
jQuery, but this """"solution" is not working because:
Each click on the add button, it duplicates the current amount of Divs with the class . prof-Exp;
Once it has completed the 1st experience and click on the "add another experience" button, all data will be cloned for the experiments below.
That is, it does not serve. What I want is simply to REPLICATE the blank fields so that the user fills them with his other experiences. How do I do that?
How do I solve this? I don’t know what else to do, I really want to solve this challenge! Thank you very much, guys, for any attempt to help.
I’m new to development and I don’t know much yet, so if I’m being too secular, excuse me