I am creating two input fields when I click the plus (+) button, I can already generate the two inputs, but I need to limit the input, I only need 5 input, I tried with while and I did not succeed, Thank you
/ creates more additive value fields and number of plots /
function duplicarCampos(){
var clone = document.getElementById('origem').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 = '';
}
}
<tr>
<td colspan="4">
<div align="center" style="font-size:12px;background: #FFDAB9;border: 1px solid rgb(161, 161, 161) " id="origem" >
<br>
Valor do Aditívo (R$): <input type="text" id="tco_valor_aditivo_new" name="tco_valor_aditivo_new[]" maxlength="14" size="14"/><br>
<br>
Número de Parcelas:
<select name="tco_num_parcelas" id="tco_num_parcelas" >
<option value="...">...</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<p>
<button type="button" style="cursor: pointer;" onclick="duplicarCampos();">+</button>
<button type="button" style="cursor: pointer;" onclick="removerCampos(this);">-</button>
<p><p><p>
</div>
<div id="destino"></div>
</td>
</tr>