Forum Moderators: open

Message Too Old, No Replies

line wrap within an option?

there are too many words to fit on one line

         

Purple Martin

3:22 am on Jul 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've got a select list, and one of the options is really long (several words). It's too long for the available interface space.

Is it possible to make words in an option wrap so the option is on two lines? Like the second option of these three:


- This is a short option
- This is a very long option
with several words
- This is a short option

tedster

5:34 am on Jul 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



First the bad news - as far as I know there is no way with straight HTML to wrap lines inside an option tag.

Now the good news (sort of.) I have seen a complex js workaround that involved multiple select and some script that made both lines select when one was clicked - but I can't find the details right now and my memory may be rusty - it was a long time ago.

But I'm pretty sure someone wrote up a work-around somewhere. Right now Google is not giving it to me however.

Purple Martin

6:22 am on Jul 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nice idea!

Actually, the JavaScript can be fairly simple. Here's what I'm going to do:

- I'll have two <option> tags, both with the same value attribute, with half the text in each (I'll give the second one a couple of non-breaking spaces to make it indent).
- When either is selected, I'll use JavaScript to just select the first one: after all, the select box (in it's "closed" position, which it will be after the click) only shows one line and it's appropriate for that line to be the first one. If anyone has JavaScript disabled it won't really matter because they'll still have the line they selected highlighted and the form will still work correctly.

:)