Bibhu
Bibhu

Reputation: 4081

how to add checkbox element to a combobox dynamically

I want to add checkbox element to a combo box / select element dynamically. I tried with this

    var option="";
    for (i = 0; i <= 5; i++) {
        option = option + '<option><input type="checkbox" name="myCheckbox" value="checkbox" /></option>';
    }
    $('#cmbRebateCategories1').append(option);

This is the HTML markup I have,

        <select id="cmbRebateCategories1">
        </select>

but its not working. Please help me out.

Upvotes: 0

Views: 736

Answers (1)

David Hedlund
David Hedlund

Reputation: 129792

This is not something that the <option> element supports. You'd have to roll your own select replacement.

jQuery UI MultiSelect Widget appears to be doing what you're requesting.

Upvotes: 2

Related Questions