Can I make an s:select list to have a static width to have the following properties
1. When the dropdown is selected, it dynamically increases based on the largest text in the list 2. When selected the list goes back to the static width.
In any case, you can only affect the <select> element via it's HTML attributes and CSS, so this has been moved to the HTML forum. [ December 07, 2008: Message edited by: Bear Bibeault ]
I tried the following javascript but it does not reset the width to 20 px once the combo is set function autoWidth() { var maxlength = 0; var mySelect = document.getElementById('test'); for (var i=0; i<mySelect.options.length;i++) { if (mySelect[i].text.length>maxlength) { maxlength = mySelect[i].text.length; } } mySelect.style.width = maxlength * 10; }
Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.
You can go back and change your post to add code tags by clicking the .
Sri Anand
Ranch Hand
Joined: Mar 06, 2005
Posts: 392
posted
0
I think width of the select tag depends mostly on the length of the text in your options list
Jay Abrahm
Ranch Hand
Joined: May 28, 2008
Posts: 182
posted
0
Hi Sri Anand -
That is what happens but the length goes all the way to 100 characters and I don't want a list that wide. Whereas if I set the width to 20 (which is all the space I have) the combo box gets clipped of.
I remember seeing websites where the dropdown is wider and then when the selection is made it narrows down but I don't seem to be lucky enough to find one now.
I even played around with trying to get a dynamic tooltip that would display the whole text, but that was a dead end as far as I know.
Sri Anand
Ranch Hand
Joined: Mar 06, 2005
Posts: 392
posted
0
I had a similar issue i could not get above this problem, Issue display seven long meesages in drop down and user needs to select one of them there were lot of fields in teh form and page lay out was messing up because of length of select solution or work around i numbered each message and below the select, i put a multi line text box and when ever a particular number is selected in select, the corresponding message of the number is displayed in the text box, thus keeping the size of the select small
its kind of work around i did to get above this problem if you are sucessful in finding better solution let me know
Jay Abrahm
Ranch Hand
Joined: May 28, 2008
Posts: 182
posted
0
Hey !!
Just what I have started with... I don't know of a better workaround, all that I need to make up my mind on now is whether, to have text in a div as label or have a textarea...
Hi Jay Abrahm!
Thanks for the source code you post above. I've been testing it and I found that this doesn't work in IE7 or IE8, but it works fine in Firefox, do you know why ? I need this solution for IE7 or IE8...
Thanks in advance ! Regards !
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.