I need to create a select with values from 1 to N numbers. After the user selects a number in the select I have to clone the lote
div from the selected value.
Example: if I select the number 2 in the select, you have to clone two divs. If I select 1, clone only one and if I select 3 clone 3.
Here's an example:
$("#qtdLote").on("change",function(){
var num=parseInt($(this).val());
//$("#grupo-lotes").html(''); //limpar antes de gerar
for(var i=1;i<=num;i++){
$("#grupo-lotes").append($("#lote").clone());
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><div><label>Escolha</label><selectid="qtdLote">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</div>
<br />
<div id="grupo-lotes">
<div id="lote">
<label>LOTE </label>
<input type="">
</div>
</div>
See codepen.io