PDA

View Full Version : Option length


atferraz
03-25-2004, 11:56 AM
How to level the length of all options in a select element if the text for each options has different size?.

Thanks

sage45
03-25-2004, 04:25 PM
You would need a javascript resolution to help with this problem...

Moving post...

-sage-

requestcode
03-25-2004, 06:02 PM
Actually I did it with CSS this way:
select {color:blue;font-weight:bold;width:200;background-color:white;}

This example will affect all selects so if you want to have separate ones for different selects then set up a class name for each one. For example:
.selecta{color:blue;font-weight:bold;width:200;background-color:white;}

Then in your select refer to it this way:
<select class="selecta" ...>

sage45
03-25-2004, 06:35 PM
That set's the width of the box... However, he is asking how he can level the text inside the box, if the text is of varying lengths...

-sage-

requestcode
03-25-2004, 07:29 PM
In that case we will need to know some more about how the select is created. If it is being created using javascript then the text could be "choped" off at a certain length. If it is static using HTML then not much can be done other than CSS.

FastCougar
03-25-2004, 10:24 PM
If it's dynamic, using ASP/JSP/ColdFusion/PHP/others, it can be truncated within the langauge before being passed to the <option>. I do this all the time in ColdFusion. I normally truncate at 27 characters and if the value is longer than 27, I add a "..." to the end of the text. I do however pass the entire string in the value since we don't want to pass truncated data, only display it truncated.

atferraz
03-25-2004, 10:42 PM
thank you guys. I've already work it out with css only.

<select style="width:200px;"