Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. assign width to a select element

assign width to a select element

Scheduled Pinned Locked Moved Web Development
javascriptdatabasehelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mahraja
    wrote on last edited by
    #1

    hi i have a select element that is created by javascript code and its options come from db. it works fine, but the problem is that the select element stretches itself to fit the longest option. and doesn't accept the width i specify/assign for it. what should i do?

    J 1 Reply Last reply
    0
    • M mahraja

      hi i have a select element that is created by javascript code and its options come from db. it works fine, but the problem is that the select element stretches itself to fit the longest option. and doesn't accept the width i specify/assign for it. what should i do?

      J Offline
      J Offline
      Jills Mathew
      wrote on last edited by
      #2

      Did you try setting the width using inline style? Add

      style="width: 100px;"

      to the select element tag and try

      M 1 Reply Last reply
      0
      • J Jills Mathew

        Did you try setting the width using inline style? Add

        style="width: 100px;"

        to the select element tag and try

        M Offline
        M Offline
        mahraja
        wrote on last edited by
        #3

        of course i did. but it has no effect on the width of select element since it stretches itself to fit the longest option. i set the width 100px, and when i inspect it in the browser, it is 400px!!!

        J 1 Reply Last reply
        0
        • M mahraja

          of course i did. but it has no effect on the width of select element since it stretches itself to fit the longest option. i set the width 100px, and when i inspect it in the browser, it is 400px!!!

          J Offline
          J Offline
          Jills Mathew
          wrote on last edited by
          #4

          can you please share the code of your select statement with us?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups