I have a dropdownlist with a very long item, this item stretches my dropdownlist which i dont want, but if i set a fix width then, the text becomes cut off.

My solution is very wierd, i want to my dropdownlist to become a listbox when my dropdown goes over a certain length.

e.g.

if (dropdownlist > width 50px) {
    //hide dropdownlist
    //show listbox
    //Get selected value of dropdown list into listbox
} 

can anyone help me with coding like this, I would really appreciate it

1 answer

danwellman 5600
1
point

What you'll probably want to do is use a custom selectbox replacement widget which transforms this specific list into a widget that you have more visual control over.

I wouldn't worry about testing for width etc in this case - you know the selectbox is not wide enough for its content so just replace it.

There are many selectbox replacements out there, you want something configurable, skinable and accessible, from a reputable agency, so something like this should do just fine: http://www.filamentgroup.com/lab/jquery_ui_selectmenu_an_aria_accessible_plugin_for_styling_a_html_select/

Answered over 7 years ago by danwellman