Auto-fill the Listbox values as selected.

Asked

Viewed 27 times

0

When the data goes to Listbox I wanted it to be selected immediately: I don’t know why it didn’t work.

 itensListBoxCatequizandos.append('<option value="' + obj.val + '"> ' + obj.name + '</option>').prop('selected', true);

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);           
        });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.