File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes  control the maximum length of text in a drop down list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark " control the maximum length of text in a drop down list" Watch " control the maximum length of text in a drop down list" New topic
Author

control the maximum length of text in a drop down list

Ananth Chellathurai
Ranch Hand

Joined: Nov 21, 2007
Posts: 349

I have drop down list which lists n number of products. When a product name is huge my drop down list gets long. Is there a way to restrict the max length of the text to be displayed, and display ... after the length.
Please advice me on this.

Ananth
[ November 22, 2007: Message edited by: Bear Bibeault ]

Ananth Chellathurai [Walk on software]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Ananth,
Do you want to restrict the length (have less than n elements in the list) or the width (have n elements but display less text for the long ones) ?

If length, you can put less entries in the list in Java. If width, you can use a CSS style to set the width of the pull down to an explicit number or pixels. Alternatively for width, you can loop through in Java, and get rid of some of the characters.

These are both technical solutions. A "better" solution would be to edit the source data to make it shorter or make a "display name" equivalent that is shorter. Sometimes chopping off data doesn't yield the best results unless a human does it.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Shane W
Ranch Hand

Joined: Aug 31, 2007
Posts: 30
Hi,If its the width you want to restrict,you can use a a CSS or otherwise (as stated in the solution above)to restrict the width.Tool tip can be used so that user can see the full terxt if it is not completely visible

Shane
Ananth Chellathurai
Ranch Hand

Joined: Nov 21, 2007
Posts: 349

I got it. Thanks for all your valuable time.

Ananth
[ November 24, 2007: Message edited by: Ananth Chellathurai ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: control the maximum length of text in a drop down list