• 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

Aligning text in combo box

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not exactly sure if this is an html question, or servlet question, but I'll try here first. Basically, I have a combo box that displays a name and user id. The name is variable length, so what I am trying to do is pad out the string so that user name + padding is set to some arbitrary length, and then the id is added so that there are two aligned columns.

I am using a loop in a servlet to generate the code, and the data is being pulled from MySql:

When I view the source of the generated html, everything is padded as I want, but the spaces are being consumed. I have tried enclosing the name in quotes; I can't think of anything else to try. I have checked both IE and Firefox to see if it was an issue with one or the other, and that doesn't seem to be the case. Any ideas on which direction I should be heading?

EDIT: I guess it would maybe be more proper to call this a drop-down list.
[ January 08, 2007: Message edited by: Chad Clites ]
 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think browser trims whitespaces unless you keep in <pre> tag.
Try adding entity reference for space. instead of tab or spaces. That may work.
I am not able to put that reference here as it is parsing and displaying space.. it consists of & symbole followed by characters nbsp.

[ January 08, 2007: Message edited by: Rizwan Mohammad ]
[ January 08, 2007: Message edited by: Rizwan Mohammad ]
 
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

Originally posted by Chad Clites:
I have a combo box that displays a name and user id.



No, you don't. You mean a select element. There is no Combo Box control in HTML.

And no, you cannot pad anything, including select options, in HTML with spaces.

You might want to try non-breaking space entities (&nbsp;) or perhaps optgroup elements
[ January 08, 2007: Message edited by: Bear Bibeault ]
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Select elements are usually displayed in proportional fonts by HTML, aren't they? In which case trying to align data by putting in spaces wouldn't work.

I suppose you could make your select element use a fixed-width font (e.g. Courier) but then your users might think it looked very strange.
 
Chad Clites
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

No, you don't. You mean a select element.



Well then I was wrong twice then because I tried calling it a drop down menu also. I am trying to use nbsp along with a mono spaced font. I had not considered optgroups.

Thanks for the input.
[ January 08, 2007: Message edited by: Chad Clites ]
 
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've also referred to them as drop-downs, and while imprecise, that's not necessarily wrong. But referring to them as Combo Boxes is flat-out incorrect.

optgroups have their own set of issues, but they may work for what you are intending.
 
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic