DS1
DS1

Reputation: 43

ASP.NET MVC combo dropdown box

Is it possible to create a dropdown box in ASP.NET MVC, that has a checkbox alongside each item in the dropdown list?

I know it sounds simple, in webforms or using telerik this would be pretty simple, but I can't figure how I can implement the same thing in basic HTML.

Thanks

Upvotes: 4

Views: 3793

Answers (2)

Webking
Webking

Reputation: 1862

You can use a jQuery plugin called DropDownCheckList to get the wanted effect of a dropdownlist with multiselect options.

alt text

Its pretty easy, all you need to do is to create a html listbox and call the jQuery plugion to extend the listbox.

<script type="text/javascript">
    $(document).ready(function() {
        $("#listbox").dropdownchecklist();
    }
</script> 

<select id="listbox" multiple="multiple">
                <option>Option 1</option>
                <option>Option 2</option>
                <option>Option 3</option>
            </select>

http://dropdown-check-list.googlecode.com/svn/trunk/doc/dropdownchecklist.html

Upvotes: 6

Stefanvds
Stefanvds

Reputation: 5916

a dropdown with each element of the dropdown having a checkbox? that's not a standard element of HTML, why would you even need that? a multiple option is what you need:

http://www.htmlcodetutorial.com/forms/_SELECT_MULTIPLE.html (first one)

Upvotes: 1

Related Questions