Im trying to create a dynamic form just with html, css, and JavaScript (or a little bit of JQuery) so my ploblem is I have this:
<div class="form-item">
<label for="form-container">Random Title:</label>
<div id="form-container">
***Here is where I add dynamic "forms"***
</div>
<div>
<button type="button" class="add-form" onclick="AddForm()">Add form</button>
</div>
</div>
and the JavaScript is (I dont know if is the best solution but at least it works haha):
function addForm(){
let container= document.getElementById('form-container');
if (cnt<5){
cnt+=1;
container.innerHTML += `***the form but write on HTML format***`;
} else {
alert("¡you cant add anymore!");
}
}
and I need something similar but to remove the forms that I added with the dynamic add button.
(form is between "" because it isnt actually a form it is just a div with inputs inside, because it is part of a bigger form with other inputs on other divs)