Apparently this doesn\'t work:
select[multiple]{
height: 100%;
}
it makes the select have 100% page height...
auto
You can do this with simple javascript...
<select multiple="multiple" size="return this.length();">
...or limit height until number-of-records...
<select multiple="multiple" size="return this.length() > 10 ? this.length(): 10;">
You can only do this in Javascript/JQuery, you can do it with the following JQuery (assuming you've gave your select an id of multiselect):
$(function () {
$("#multiSelect").css("height", parseInt($("#multiSelect option").length) * 20);
});
Demo: http://jsfiddle.net/AZEFU/
For jQuery you can try this. I always do the following and it works.
$(function () {
$("#multiSelect").attr("size",$("#multiSelect option").length);
});
friends: if you retrieve de data from a DB: you can call this $registers = *_num_rows( Result_query ) then
<select size=<?=$registers + 1; ?>">