Mel Smith wrote on 10 feb 2013 in comp.lang.javascript:
> Evertjan:
>
> I managed to get the <select> list to drop down on focus. However
> (as
> the example below shows), the set of inputs on the same line as the
> select get 'pushed down' and destrop the screen layout.
>
> Can you give further guidance please ??
As I wrote,
you will have to do this with a css position command, like:
position:fixed;
or
position:absolute;
It just takes some playing with these css-settings, I trust.
I am not an expert in this,
I would do the same experimental testing as you could.
> function setFocusSize(selobj) {
> if (
selobj.id == "imth") selobj.size = "13" ;
>}
>
> function resetFocusSize(selobj) {
> if (
selobj.id == "imth") selobj.size="1" ;
>}
Why test for the specific object?
The eventhandlers in the object link the use to that object.
Methinks, more compact,
[and the one function can be used for different select objects]:
==========================================
function changeFocusSize(selobj,size) {
selobj.size = size;
};
<select size='1'
onfocus='changeFocusSize(this,13);'
onblur='changeFocusSize(this,1);'
>
===========================================
or even shorter
[I prefer this, no distant functions necessary,
it shows exactly what you want it to do]:
==========================================
<select size='1'
onfocus='this.size = 13;'
onblur='this.size = 1;'
>
===========================================
> <select id="imth" size="1" onfocus="setFocusSize(this);"
> onblur="resetFocusSize(this);">
> <option value="XXX" disabled="disabled">Pick Month</option>
No need for a value here,
what is the intended effect of your disabling?
> <option value="Jan">January</option>
> <option value="Feb">February</option>
> <option value="Mar">March</option>
> <option value="Apr">April</option>
> <option value="May">May</option>
> <option value="Jun">June</option>
> <option value="Jul">July</option>
> <option value="Aug">August</option>
> <option value="Sep">September</option>
> <option value="Oct">October</option>
> <option value="Nov">November</option>
> <option value="Dec">December</option>
I would be using serverside code,
perhaps needing the months names elsewhere to,
and perhaps translate the page to another natural language:
<%
var mnds = ['January','February','March','April','May','June',
'July','August','September','October','November','December'];
for (var i=0;i<11;i++)
Response.write "<option value='" +
m[i].substr(0,3) +
"'>" +
m[i] +
"</option>";
%>
> </select>