View Full Version : expanding dropdown/select box???
01-02-2007, 11:54 PM
Hello all. Not sure if this is the correct forum, but here it goes. I was just wondering if anyone out there knows of a way to have a dropdown/select box set to a fixed width i.e. 125px, but when you open it, the dropdown portion will automatically expand to the largest item in the list, and when you select the item, have the dropdown resize back to the 125px size?
Thanks in advance,
01-03-2007, 03:04 PM
The solution to your problem is somewhat in the following direction (combination of server and client scripting):
onclick="this.style.width='<% = maxOptionWidth %>px';"
maxOptionWidth is a variable that holds the width of the longest text in select control - you have to determine the width by yourself when building the values - I don't know whether there is a built-in function that would return character width in ASP (similar to Printer.TextWidth in VB6).
Hope this helps.
01-03-2007, 04:22 PM
Thank you. I'll give that a try!
01-12-2007, 04:30 PM
<form name="form1" method="post" action="">
<select name="select" style="width: 100px;" onmousedown="this.style.width=''" onblur="this.style.width='100px'">
<option value="item1">This is item1 this is more text</option>
01-12-2007, 04:53 PM
That was AWESOME and worked great!
Thank you so much. Actually, thank you both.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.