• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

spaces in select/option tag dropdown menu

 
Anand Gondhiya
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • 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
 
Pablo M�ller
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried with NEW  YORK SUMMARY ?
Good Luck!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • 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.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic