<select><option><input type="checkbox" />Headache</option></select>
By using the above code i did't get a check box inside a dropdown list.Can you suggest me , how should i proceed.
<select><option><input type="checkbox" />Headache</option></select>
By using the above code i did't get a check box inside a dropdown list.Can you suggest me , how should i proceed.
You can't have an input control inside a select element. You'll have to create the drop-down using JavaScript, without using the select element at all.
That's not possible with "plain" HTML, you'll need to grab JavaScript to progressively enhance a plain dropdown into such a dropdown with help of <ul><li>
elements and a good shot of CSS. You can find here an overview of what's all possible with jQuery (a JavaScript library), such as the jQuery dropdown checklist.
It's pretty simple, just import the desired JS libraries and apply it:
<!doctype html>
<html lang="en">
<head>
<title>Dropdown with checkboxes.</title>
<script src="jquery.js"></script>
<script src="dropdownchecklist.js"></script>
<script>
$(document).ready(function() {
$("#select_id").dropdownchecklist();
});
</script>
</head>
<body>
<select id="select_id">
...
</select>
</body>
</html>
That's all.
Another approach on top of BalusC's one is to actually develop your own custom UI element. Unfortunately, this is usually (or always?) browser-specific.
I know you can do that for Firefox using XUL.
I'm sure you can do some ActiveX tricks for IE though no clue how.
The reason that didn't work is that form elements don't nest like that. Fortunately, there's a jquery plugin that can do what you want. http://abeautifulsite.net/2008/04/jquery-multiselect/