SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Option in select on multiple lines?

    Hi all
    For design reasons I am wondering if this is possible? It is for a dynamically populated select field Thanks

  2. #2
    SitePoint Addict bronze trophy AllanP's Avatar
    Join Date
    Sep 2010
    Location
    Australia
    Posts
    298
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yes, you can use javascript to build a dynamic select element with dynamic <option> elements. You can also use the selection from one select element to populate the options in a second or subsequent select elements.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,807
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    I have not come across any way that it can be done.

    You can use CSS to set a maximum width for the select list but there is no way to get the entries that are too wide to display as one line to display as two lines as the content of the option cannot contain HTML and ignores all surplus whitespace (including any representation of a new line character).
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    Non-Member
    Join Date
    Jun 2010
    Location
    4727′35″N 2618′0″E
    Posts
    1,789
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can only provide this type of thing by not using the traditional select and option html elements.

    You do that by progressive enhancement: build your markup using select and option elements, then, by javascript code or server side code, you replace them with other html elements that have the ability to break their text content on more then one line and build the functionality for them to mimic the select and option elements behaviour.

  5. #5
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for the replies really appreciated


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •