I am making an ordering page, where you can register several products.
In order to register the products the users have the options of Produto, quantidade, valor, subtotal
, if they want to add another product, it has a function that adds one more line of these fields.
MyproblemisthatI'musingSelect2tofetchtheproductsinthedatabase,butSelect2willonlyworkinthefirstproductfield,soifIaddanotherproduct,itdoesnotwork.
Youmaynoticethattheproductfieldshaveadifference,sinceonewithSelect2andanothernot.
TheJScodeI'musingforthissearchisthis:
$("#produto" ).select2({
ajax: {
url: "modulos/orcamentos_funcao.php?buscar=produto",
dataType: 'json',
delay: 250,
data: function (params) {
return {
q: params.term // search term
};
},
processResults: function (data) {
// parse the results into the format expected by Select2.
// since we are using custom formatting functions we do not need to
// alter the remote JSON data
return {
results: data
};
},
cache: true
},
minimumInputLength: 1
});
In short, I need a dynamic search for products.