• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

length of select item

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'd like to create a <select> field. By default the length of this field is defined by the longest <option>. Is it possible to say to the <select> field:
OK, take the longest <option> but if it's longer than a given maximum then take this maximum as length of the select field.
(The length of the longest <option> is not known in advance because the options are retrieved in a JSP dynamically at runtime. Even though JSP is involved I think it's basically an HTML question)
If it's not possible to define a maximum length for a <select> field, is there a workaround to shrink the length of the <select> field?
Regards
Ruediger
 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See if this snippet works -

HTH,
- Manish
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no attribute for the select tag using which u can set the length of the select box.
But u can achieve the desired effect using style sheets.
Define a style (using CSS) using smaller font size and use this style class for the select tag so that u can reduce the space taking up by the select tag.
anybody else has a better solution???
 
Ruediger Waurig
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've checked out the solution proposed by Manish and ...
it works perfectly for IE
but unfortunately not for Netscape Navigator
Has anybody an idea whether there is an equivalent of Manish's solution for Netscape?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It should work fine for "modern" versions of Netscape. For older versions of NN, you cannot adjust the length; it will size the dropdown according to the length of the longest entry.
One way to "trick" it is to specify a single HTML option tag with a string that sets the width to what you want, then, in an onload handler, replace the options with the "real" entries.
But (bear gets on to his usual sopabox), do you really think that it is worth all this pain and aggravation to support a browser with a market share that is measured in fractions of a percentile?
hth,
bear
[ April 24, 2003: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is an old thread but I'm having the same problem - I need to dynamically set the max width of a select box. I can make the style sheet idea mentioned here work, but not dynamically.

Any help out there?

Many Thanks!
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I can make the style sheet idea mentioned here work, but not dynamically.



Huh?
 
Gail Schlentz
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the quick reply...
The suggestion from the post by Manish Hatwalne:

works, but I need to be able to do something like this: (which hasn't worked...)

Thanks!

[ June 23, 2004: Message edited by: Elaine Micheals ]
[ June 23, 2004: Message edited by: Elaine Micheals ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Gail Schlentz
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:



Bear,

You Rock! Thanks!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic