Automatically fill Listbox values as selected.

0

When the data goes to the ListBox, it wanted to be selected immediately: I do not know why it did not work.

 itensListBoxCatequizandos.append('<option value="' + obj.val + '"> ' + obj.name + '</option>').prop('selected', true);
    
asked by anonymous 20.04.2016 / 16:22

1 answer

0

Okay. I solved the problem:

 $.each(myCheckboxes, function (i, obj) {
            itensListBoxCatequizandos.append('<option value="' + obj.val + '"> ' + obj.name + '</option>');    
            $("select option[value=" + obj.val + "]").attr("selected", true);           
        });
    
20.04.2016 / 16:59