Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set the width of a SELECT form field 1

Status
Not open for further replies.

nrussell

Technical User
Mar 3, 2005
5
GB
Anyone know how to do this ?

I have a page with 3 SELECT form fields on it, all one above the other.
The OPTION elements for each field are populated from a database.
The width of each field automatically gets set to the width of the widest OPTION element.

What I'd like to do is write some JS that resizes the width of the fields to the width of the widest field so they all look neat and lined up - does this make sense ?

Any help with this would be very much appreciated.

Thanks

Nathan
 
ya it makes sence, its nice that some developers dont only care about the code but what the user interface looks like as well.

with most controls, even if there is not a width property you can still control the width using styles. so instead of using... width="50"... you could type... style="width:50;"

the javascript access for this is ass follows:

----------------------------------------

CONTROL_NAME.style.width=YOUR_BIGGEST_LENGTH;

----------------------------------------

hope that helps
 
See thread216-1028716 for more info

Adam

Whatever I feel like I wanna do, gosh!
 
Thanks to all who replied, and in particular adam0101 !
Cheers guys !
Nathan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top