JavaScript

Moderators: None (Apply to moderate this forum)
Number of threads: 2061
Number of posts: 5164

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
help on String Posted by mrQuestion on 14 Apr 2006 at 9:59 AM
Hi all,

I have a question regarding displaying a string in javascript. Ok, I have a collection of string in a variable and i am iterating it through a loop for display. Each string has spaces that seperate column 1 from column 2, but both columns are in one string. For example:

This is my string 1<space><space><space><space><space>Also my string 1.
This is my sring 2<space><space><space><space><space>Also my string 2.

Where <space> = empty white space.
The problem is, when it display in the brower (in my html table), all the spaces get striped off. So, it looks like this:

This is my string 1 Also my string 1.
This is my string 2 Also my string 2.

I don't understand why it does that. Is it because of javascript?
How would i go about in displaying the string the way it suppose to look?

Please replay. Thanks.
Report
Re: help on String Posted by zibadian on 14 Apr 2006 at 12:02 PM
: Hi all,
:
: I have a question regarding displaying a string in javascript. Ok, I have a collection of string in a variable and i am iterating it through a loop for display. Each string has spaces that seperate column 1 from column 2, but both columns are in one string. For example:
:
: This is my string 1<space><space><space><space><space>Also my string 1.
: This is my sring 2<space><space><space><space><space>Also my string 2.
:
: Where <space> = empty white space.
: The problem is, when it display in the brower (in my html table), all the spaces get striped off. So, it looks like this:
:
: This is my string 1 Also my string 1.
: This is my string 2 Also my string 2.
:
: I don't understand why it does that. Is it because of javascript?
: How would i go about in displaying the string the way it suppose to look?
:
: Please replay. Thanks.
:
Normal space characters (#32) are always compacted to 1 space by browsers. It is part of the HTML specification. To get multiple spaces after each other use the "non breaking space" code: "&nbsp;".



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.