Link to home
Start Free TrialLog in
Avatar of amirup
amirup

asked on

fixed size for dropdown list

How to fix/limit the size of drop down. for ex size should be 30 where as one of the value has 50 charecters but i want to show only 30. can we control this.
ASKER CERTIFIED SOLUTION
Avatar of darksinclair
darksinclair

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dfu23
dfu23

CSS

<select style="width:200px;">
    <option> ...
</select>

Set the width to the desired size ...
dfu23 - this is not related to dropdown width...it's about character in the dropdown.
ah yes, thanks alorentz.  Good eye. ;)
@alorentz - How can you be so sure? The above question is vague enough to where if  amirup didn't know what CSS could do for him he might think that the only option he had is to remove characters from the drop down to set it to a specific size. Certanly there is nothing wrong with dfu23 giving an alternate solution which might better suit a fixed width select box. dfu23's solution also has the added benifit of not caring about the width of the character in the select box, so a box filled with 30 i's will still be the same length as a box filled with 30 w's.
I was kind of intrigued by how dfu23's solution would work so I decided to make a little test script,

a nice solution, Im not sure I like the fact that the text goes all the way to the end of the box and the other information is there just not shown,,, but still a fairly simple solution.  

Here is my test if anyone wants to see the who different styles.

Cheers,

<%
dim output
output = "123456789012345678901234567890wwwwwww"
%>
<% 'Option #1 %>
<select>
<option>
<%
if len(output) > 30 then
   Response.Write( Left(output,30) & "..." )
else
   Response.Write( output )
end if
%>
</option>
</select>

<% 'Option #2 %>
<br>
<select style="width:200px;">
    <option><%=output%></option>
</select>
"a nice solution, Im not sure I like the fact that the text goes all the way to the end of the box and the other information is there just not shown"

Were you testing in IE? Both Netscape and FireFox will actually display all the text when you click the dropdown. IE unfortunately still cuts it off even when you click the dropdown.
Avatar of amirup

ASKER

wanna share points between alorentz, darksinclair
thanks to both ....


alorentz u r solution is "luxury" to the solution given by darksinclair .... but u forgot to decrease the size of charecters to 27 as u r adding 3 additional charecters "...".
Thanks to both of you.

BTW any idea how to share the points?