PDA

View Full Version : setting the width of SELECT fields



dwbh
Jul 2nd, 2002, 09:28 PM
OK, this is one of those questions that I'm going to kick myself over when I finally hear the answer, but here we go...

I'm using JavaScript to create dynamic choices for some <SELECT> fields, and it works fine in itself. However, since the available choices aren't the same for every generated <SELECT> field, the fields come out sized differently. Check out the attached screen shot and you'll see what I mean. Does anyone know how to set the width of <SELECT> fields to be a consistent size? The SIZE property controls the height, or how many choices are visible at once. What I want is something similar to the SIZE property for <INPUT> fields. Thanks!

dwbh
Jul 2nd, 2002, 09:54 PM
OK, I answered my own question. You can use the STYLE attribute to set the WIDTH property, like so:

<SELECT NAME="Test" STYLE="width: 100px">
<OPTION>Choice 1
<OPTION>Choice 2
<OPTION>Choice 3
</SELECT>

In place of pixel size, you can also use percentage values, e.g. STYLE="width: 50%".

Hope this helps somebody,
Sam