0
I have a dynamic form (that) with two fields (a SELECT and a quantity input), but every time I add two more fields SELECT gets stuck.
$(document).ready(function(){
var itemCont = 1;
$("#novoProd").click(function(){
var novoItem = $("#item").clone();
// modifica o id do item recem criado
$(novoItem).attr("id","item"+itemCont);
var novoSelect = $(novoItem).children()[1];
$(novoSelect).attr("id","produtoId"+itemCont);
$(novoSelect).attr("name","produtoId[]"+itemCont);
var novoSelect = $(novoItem).children()[3];
$(novoSelect).attr("id","quant"+itemCont);
$(novoSelect).attr("name","quant[]"+itemCont);
$("#formulario").append(novoItem);
itemCont++;
$("#itemCont").val(itemCont);
});
I’m using the plugin Chosen to create the search field in SELECT, without it the form works normal.
<select data-placeholder="Choose a Country..." class="chosen-select" id="produtoId" name="produtoId[]">
What do you mean "stay locked"?
– Sam
Check for an error in the console.
– Paulo Ramos
@dvd, SELECT options do not appear.
– Gabriel Tobias
@We step, does not point out any error.
– Gabriel Tobias