seguret
asked on
sizing a select
I have this HTML code :
<TABLE>
<TR>
<TD BGCOLOR='#28A7F6' ALIGN='CENTER'>
Aspect
</TD>
</TR>
<TR>
<TD ALIGN='CENTER'>
<select name=servicesPossibles1 size=3>
<option>A</option>
<option>B</option>
<option>C</option>
</select>
</TD>
</TR>
</TABLE>
(in fact, it's dynamic code).
It shows a title with a select. My problem is :
I don't want my select to be shorter than the title (the first cell of the table).
How do you set the width of the selct to be the one of the cell ?
<TABLE>
<TR>
<TD BGCOLOR='#28A7F6' ALIGN='CENTER'>
Aspect
</TD>
</TR>
<TR>
<TD ALIGN='CENTER'>
<select name=servicesPossibles1 size=3>
<option>A</option>
<option>B</option>
<option>C</option>
</select>
</TD>
</TR>
</TABLE>
(in fact, it's dynamic code).
It shows a title with a select. My problem is :
I don't want my select to be shorter than the title (the first cell of the table).
How do you set the width of the selct to be the one of the cell ?
1. Let the id of the cell be "c1" whose width is to be assigned to <SELECT>
2. Let the id of the <SELECT> be "s1"
Write a function at the client side:
<SCRIPT LANGUAGE=javascript>
<!--
function f()
{
s1.style.width = c1.clientWidth;
}
//-->
This function can be called at the onLoad event of the <BODY>
2. Let the id of the <SELECT> be "s1"
Write a function at the client side:
<SCRIPT LANGUAGE=javascript>
<!--
function f()
{
s1.style.width = c1.clientWidth;
}
//-->
This function can be called at the onLoad event of the <BODY>
1. Let the id of the cell be "c1" whose width is to be assigned to <SELECT>
2. Let the id of the <SELECT> be "s1"
Write a function at the client side:
<SCRIPT LANGUAGE=javascript>
<!--
function f()
{
s1.style.width = c1.clientWidth;
}
//-->
This function can be called at the onLoad event of the <BODY>
2. Let the id of the <SELECT> be "s1"
Write a function at the client side:
<SCRIPT LANGUAGE=javascript>
<!--
function f()
{
s1.style.width = c1.clientWidth;
}
//-->
This function can be called at the onLoad event of the <BODY>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That doesn't work : in fact, I cannot eve access to c1.clientWidth : the following code does nothing :
alert(c1.clientWidth);
alert(c1.clientWidth);
Yes Max. is right on; you need to use css to widen your select box; thats the only way;
but just to ensure that all comes in your can change the font and size;
<select name="servicesPossibles1" width="20" style="width:30px; font-family:verdana; font-size:10px; letter-spacing:0px;word-sp acing:0px; ">
lexxwern
but just to ensure that all comes in your can change the font and size;
<select name="servicesPossibles1" width="20" style="width:30px; font-family:verdana; font-size:10px; letter-spacing:0px;word-sp
lexxwern
ASKER
Thanx Maks, it works.
You're welcome sequret...
But if it worked....why the Grade B?
Max.
"Max is like a dream which glides in and out of the dark corners of Experts-Exchange like the early morning mist in a river delta..."
-Netminder-
But if it worked....why the Grade B?
Max.
"Max is like a dream which glides in and out of the dark corners of Experts-Exchange like the early morning mist in a river delta..."
-Netminder-
if you cannot get the object with id "c1", try the following:
alert(document.getElementB yId("c1"). clientWidt h);
alert(document.getElementB
2. Let the id of the <SELECT> be "s1"
Write a function at the client side:
<SCRIPT LANGUAGE=javascript>
<!--
function f()
{
s1.style.width = c1.clientWidth;
}
//-->
This function can be called at the onLoad event of the <BODY>