...

View Full Version : expanding dropdown/select box???



parallon
01-02-2007, 10: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,

Parallon

bostjank
01-03-2007, 02:04 PM
The solution to your problem is somewhat in the following direction (combination of server and client scripting):


<select name="select"
style="width:125px;"
onclick="this.style.width='<% = maxOptionWidth %>px';"
onblur="this.style.width='125px';">

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.

parallon
01-03-2007, 03:22 PM
Thank you. I'll give that a try!

Parallon

degsy
01-12-2007, 03:30 PM
<form name="form1" method="post" action="">
<select name="select" style="width: 100px;" onmousedown="this.style.width=''" onblur="this.style.width='100px'">
<option>item</option>
<option value="item1">This is item1 this is more text</option>
<option>item</option>
</select>
</form>

parallon
01-12-2007, 03:53 PM
That was AWESOME and worked great!

Thank you so much. Actually, thank you both.

Parallon



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum