Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

checkbox within the dropdown

Tags:

html

jquery

css

I am trying to get checkboxes within a select dropdown (multiple) as below:

<select name="select_dd" size="5" multiple>
       <option value="1"><input type="checkbox" name="chk_val" value="1" />1</option>
</select>

I think the above is not a valid one as the checkboxes are appearing outside the select.

So I tried a different approach:

<div id="selectlist">
    <ul>
        <li><input type="checkbox" name="chk_val" value="1" />1</li>
        <li><input type="checkbox" name="chk_val" value="1" />1</li>
    </ul>
</div>

and then using css to style the div

#selectlist{
border:1px solid;
height:50px;
overflow-y:scroll;
width:auto;
text-align:left;

}
#selectlist ul{
list-style-type: none;
}

is this a good approach? Can anyone suggest if there are other alternatives available for this kind of use like using jquery plugins.

like image 872
DG3 Avatar asked Feb 24 '23 21:02

DG3


1 Answers

See this:
http://harvesthq.github.com/chosen/
or this:
http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/
or this:
http://code.google.com/p/jquery-tree/
or this:
http://code.google.com/p/dropdown-check-list/
or this for an ASP.NET control:
http://www.codeproject.com/Articles/24205/MultiSelect-Dropdown-Control

like image 182
Stefan Steiger Avatar answered Feb 26 '23 23:02

Stefan Steiger