Link to home
Start Free TrialLog in
Avatar of jonleehacker
jonleehacker

asked on

Setting the maximum width for a Select box

Hi,

I have a Select box that is populated from a database. Some of the entries are 15 characters wide and some are 50. I'd like to be able to set a maximum width for the box of say 20 characters and just cut off (or better yet have a scroll bar like with a Textarea tag).

Here's a sample of the code.

<td>
<div align="right"></div>
     search by employer:
     <form name="form3" method="get" action="results.cfm">
     <select name="mnuEmployer">
     <cfloop query="rsEmp">
          <option value="<cfoutput>#rsEmp.Employer#</cfoutput>" ><cfoutput>#rsEmp.Employer#</cfoutput></option>
     </cfloop>
     </select>
     <input type="submit" value="Submit" name="empbut">
     </form>
</td>
</tr>

Thanks for the help,

Jon
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DreamMaster
DreamMaster

The best you can do for older versions is this:

<select width="50" style="width:50px">
  <option style="overflow:scroll">Scrollbar in option</option>
</select>

The "width=50" part works for netscape as long as the width of the select is shorter. When it gets longer, Netscape looses it, it just wont make it smaller (and I am talking versions 4)

So far, this is the best I have ever been able to do for the looks of select boxes in the different browsers, and don't even mention the browsers on a Macintosh, these have even different sizes for form fields.

I hope this helps a little however.

Max.