Click to See Complete Forum and Search --> : Width of a Select box


Superfly1611
12-15-2003, 07:45 AM
Hello,

I have a form on which there are 3 select boxes, they can each have a random width as they are dynamically generated.
Question...
I want these select boxes to be of equal width.
I'd like a javascript to detect which select box has the largest width and apply that width to them all.

I presumed it would go something like this....

var formElement = document.getElementById("Select1");
var l = formElement.width;
var formElement = document.getElementById("Select2");
if(formElement.width > l)
{
l = formElement.width;
}
var formElement = document.getElementById("Select3");
if(formElement.width > l)
{
l = formElement.width;
}

with l obviously being the maximum width of the 3 select boxes

unfortunately it would appear that width is not a valid property of a select box?

Can someone help me?

Superfly1611
12-15-2003, 07:50 AM
Balls!

Don't you just hate it when you post a thread like this and then realising the sollution about 30 seconds after posting....

the Selects are inside table cells.... just style="width:100%" on each Select box.

fredmv
12-15-2003, 11:58 AM
This will make things a little eaiser. ;)<style type="text/css">
/*<![CDATA[*/
td select {
width: 100%;
}
/*]]>*/
</style>Now you don't have to apply it to each seperate one. That code will do it for every single <select> element which is inside a <td> element.