Web Analytics Made Easy -
StatCounter setting the width of SELECT fields - CodingForum


No announcement yet.

setting the width of SELECT fields

  • Filter
  • Time
  • Show
Clear All
new posts

  • setting the width of SELECT fields

    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!

  • #2
    OK, got it

    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

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

    Hope this helps somebody,