Wrapping select list options... Can it be done?

I'm setting up a select list with some very long options -- long enough so they must be wrapped to fit on many screens.  How can I set these options up to have this result?  Is it possible?
(Also see my server reset question under ColdFusion.)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The select field is filled with the data passed by the <option> field.  You can not just set a 'length' parameter to this option.  You can however set the length of the option being passed to the field via dB field parameters, i.e. LongVar(length=20)... If your option list is being built dynamically this is painless;

In ASP suppose you are building a option list from data in a simple dB, first we parse the dB table for all it's contents;

PSQL = "SELECT * FROM Test99 Order by Country;"
objRS.Open PSQL, objDC, 3, 3

Then we begin building the option list;

<OPTION> Select a Name&nbsp;</OPTION>
Do While Not objRS.EOF

But first we need to limit the string length to a usable length;

testField = objRS.Fields("test")
testField = Left("testField", 20)

<OPTION VALUE="?test=<% =testField %>"> </OPTION>

Now loop through so every field is set to 20 characters;


But this is only if you are building the list dynamically.  Which you should be doing anyway... ;-)

if testField's length is more than 20 or dynamical?

testField=Left("testField",20) has cut it into a short one, what about the data after the 20th char?
can u help me?
pbuzzellAuthor Commented:
I want the options to wrap, so no info is left out and each user's monitor is used to the max.
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Freshmeat, the data is essentially remeoved from the variable, suppose this, I parse in a string from a dB field that contains brief descriptions of widgits, I then build an option list using the above script, the returned html code would look like this;

<select ...>
<option>This is a brief desc
<option>This can also be a b

So it doesn't matter how much data is in the field, it will only return 20 characters, the field data does not change.

pbuzzell,  There is no way to "wrap" the contents of a option list, you can use the DHTML property "offsetWidth" to determine the width of a client document, then scale the list contents to the element width...

Read about it here;


and the equivalent value for Netscape 4.x users is window.innerWidth.

the options won't wrap untill somebody writes a browser that does it.  neither Netscape 4.x nor IE5 wraps, even with a <br> in the middle of the option.  so, you'll either have to make sure the content of each option is no longer than what you prefer, or use CSS to set the width (which is sadly enough not supported by Netscape 4.x, but will probably be supported in Mozilla/Netscape 5).  the problem I found with the CSS approach is that IE(5) doesn't show the content of the whole option, so you get the same result as if you chopped of the content (like mgfranz suggested).

if you still want to keep the select you're SOL, so you'd might want to reconsider using it and look for more useful solutions that allow wrapping (radio buttons maybe?).


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pbuzzellAuthor Commented:
I was afraid I was SOL, but didn't want to go through the BS of radio buttons.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.