How to create a drop down list with check boxes inside it using plain Html and javascript? If not possible, can there be a chance to meet this requirement using c#.net? Kindly, help me.
Asked
Active
Viewed 2,744 times
4
-
As Im a newbie, code snippets would be of great help!! – user1545987 Jul 23 '12 at 13:36
4 Answers
1
Try this. It turns multiple select into a dropdown list with checkboxes

Clyde Lobo
- 9,126
- 7
- 34
- 61
-
Your example exactly suits my requirements but unable to understand the source code of it properly. can you give a simplified small example of it pls? – user1545987 Jul 23 '12 at 14:26
-
You just need to include the js file. And after that you need to write `a$.WhenToUse = 'class'; ` where `class` is the class that you apply to multiple select that you need to behave as if they are with checkboxes – Clyde Lobo Jul 23 '12 at 14:31
0
Create your own DropDownList.
- C#.Net approach : This is exactly what you need. I won't copy the code since it is clearly explained in the link.
HTML / JS Approach :
<html> <head> <title>Scrolling Checkboxes</title> <script type="text/javascript"> </script> </head> <body> <div id="ScrollCB" style="height:150;width:200px;overflow:auto"> <Label><input type="checkbox" id="scb1" name="scb1" value="1" />First Item</Label><br /> <Label><input type="checkbox" id="scb2" name="scb2" value="2" />Second Item</Label><br /> <Label><input type="checkbox" id="scb3" name="scb3" value="3" />Third Item</Label><br /> ... </div> </body> </html>
You can try it here : http://jsfiddle.net/aUQdW/

phadaphunk
- 12,785
- 15
- 73
- 107
-
`input` types and `line breaks(br)` are both stand alone tags and should be closed like `
`. Also associating labels with checkboxes would be great, since clicking on the label would select/de-select the associated checlbox – Clyde Lobo Jul 23 '12 at 13:50 -
I cannot see checkboxes like present in Dropdown list. Is any modification needed to this code? – user1545987 Jul 23 '12 at 14:14
0
For Dropdown list with checkbox in C sharp you have to use CheckedListBox of Windows Conntrol.Using some Properties ,you can get what you want .You can set Checked-Unchecked for item in list .

Alok
- 342
- 2
- 8
-
I'm using MVC3 architecture. I need the checkboxlist in the view. Could you pls put some codesnippet of that checkboxlist? – user1545987 Jul 23 '12 at 14:11