0
I need to add to the object Select
the Id
and the Texto
from that function:
//Adiciono o item retirado da table html para o objeto html Select
$.each(_arrDescricao, function (text, key) {
var option = new Option(key, text);
$('.selListaItem').append($(option));
});
the problem is I can only add the text
, how do I add the Id
in the Select
?
This is the complete code:
$(document).on("click", ".btnRemoverItem", function (e) {
e.preventDefault();
var _arrId = new Array();
var _arrDescricao = new Array();
$("#tableHtml tbody").find('input[type="checkbox"]').each(function () {
if ($(this).is(":checked")) {
var _id = $(this).closest('tr').find('td[data-id]').data('id');
var _descricao = $(this).closest('tr').find('td[data-descricao]').data('descricao');
$(this).closest('tr').remove();
_arrId.push(_id);
_arrDescricao.push(_descricao);
};
});
//Adiciono o item retirado da table html para o objeto html Select
$.each(_arrDescricao, function (text, key) {
var option = new Option(key, text);
$('.selListaItem').append($(option));
});
});
I still don’t understand your doubt, you want to put together a list of options of a select with a certain ID and certain TEXT (value)?
– Guilherme IA
That’s right! I already have the id =
_id
and the text =_descricao
.– hard123