Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling form pull-down field length

Status
Not open for further replies.

bamboo

Programmer
Aug 22, 2001
89
US
Trying to control the width of multiple pulldown menus within a form. In a quick example below, all boxes would be a different length due to the text. I have tried adding in a   and it seems to work ok, but still not exact and it only works in IE. As you can see with my example, each pulldown will produce a different length.

<form method="post" action="example.htm">
<select name="pulldown1">
<option value="test1.htm">Test1</option>
<option value="test1.htm">Testing2</option>
</select>

<select name="pulldown2">
<option value="test1.htm">Testingagain3</option>
<option value="test1.htm">Testingonceagain4</option>
</select>
</form>

 
The Select box automatically adjusts to disply the longest item - shorter ones are followed by whitespace.

You can adjust the number of options shown at any one time by using

<select name="test" size="3">

which will display the top three values in a list with scrollbars if there are more options.
 
Couldn't you just put in an optgroup that's longer than any of the entries in either list? Such as this:
Code:
<form method="post" action="example.htm">
<select name="pulldown1">
<optgroup label="---------------------------">
<option value="test1.htm">Test1</option>
<option value="test1.htm">Testing2</option>
</optgroup>
</select>
<br>
<select name="pulldown2">
<optgroup label="---------------------------">
<option value="test1.htm">Testingagain3</option>
<option value="test1.htm">Testingonceagain4</option>
</optgroup>
</select>
I know it's not the proper use of an optgroup, but it does seem to work for setting the width of the select list.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top