• 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

spaces in select/option tag dropdown menu

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a dropdown menu which is populated with a value 'NEW YORK SUMMARY'.
Please note that there are 2 spaces after NEW.

When dropdown menu is displayed in browser , I see 'NEW YORK SUMMARY'. ,i.e one space removed.

because of this my validations further are failing. Can somebody advise on this ?

Thanks
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried with NEW  YORK SUMMARY ?
Good Luck!
 
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
Issue #1: Why would your validations depend upon the display text of a select option? That's pretty fragile. I'd revisit this design.

Issue #2: HTML collpases whitespace. Perhaps you could try   character entitites?
 
Anand Gondhiya
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes , i tried with NEW YORK SUMMARY with 2 spaces , it replaces multiple spaces with one space.


Issue #1: Why would your validations depend upon the display text of a select option? That's pretty fragile. I'd revisit this design.



the populated dropdown , comes directly from database columns. so NEW YORK SUMMARY (with 2 spaces) comes directly from tables and I am checking my displayed value against the table value. If displayed value's space is preserved , It makes the validation straight forward.

Perhaps you could try   character entitites?



I don't know what kind of values I might recieve, so I can't use &npbsp
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Bibeault said it's not a good design to do exact text match. However if you don't have much control the design then you can use <pre> tag for each option element. This will preserve the text.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When the browser renders the page it basically does a trim() method to wipe out all the extra crap in it unless it is in a pre.

To preserver the whitespace is a select you need to change the spaces over to its approproate entities. So that means you are going to have to do a replace method of the data returned from your database before it is displayed.



Eric
 
Pablo M�ller
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again,
My last post had two   between NEW and YORK... But they were rendered as html... which it was
Sorry if it wasn't clear
Pablo
 
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

so NEW YORK SUMMARY (with 2 spaces) comes directly from tables and I am checking my displayed value against the table value



OK, I was apparently too subtle in my first post. Let me be clearer:

Relying upon the DISPLAY value of the option means that your design is BROKEN!

In other words:



is wrong wrong wrong!

Rather, do it correctly with:



and any spaces in the value will be preserved.
[ February 26, 2007: Message edited by: Bear Bibeault ]
 
If you send is by car it's a shipment, but if by ship it's cargo. This tiny ad told me:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic