views:

18

answers:

2

I've implemented this on mouseover and onmouseout like so:

<select size="3" onmouseover="this.size=this.options.length;">

This is all well and good, except i don't want it only on mouseover, i want it always :) forever.

Thanks in advance.

A: 
<select size="3" onmouseover="this.size=this.length;">
    <option>hello world 1</option>
    <option>hello world 2</option>
    <option>hello world 3</option>
    <option>hello world 4</option>
    <option>hello world 5</option>
    <option>hello world 6</option>
    <option>hello world 7</option>
    <option>hello world 8</option>
</select>

this worked for me :)

Maikel
Maybe i didn't explain my question properly but i want it to dynamically increase without the onmouseover action. That is, in your example i want the size to be 8 without the mouseover action.
superspace
A: 

Update it on DomReady.

window.onDomReady = function() {
    var a = document.getElementById('yourId');
    a.size = a.length;
}
Robert
I suppose this is the only way to do it, i was hoping to be able to somehow declare it within the select tag itself
superspace
You could theoretically create the event for onfocus, and then on load focus the element which will cause the event to trigger.
Robert