469,600 Members | 2,235 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,600 developers. It's quick & easy.

Embedding Non-Breakable Spaces into Strings -- How?

I have a list of variables and values (merge fields for a merge program) and
I want to put them in a list in a <SELECT> object. I'd like them to be
lined up, with an "=" midway between the field and the value. I was going
to fill the space between with spaces, but I noticed a number of spaces are
condensed to one (like in all other parts of HTML). I tried filling it
with non-breakable spaces, like this:

var line = "MyMergeField&nbsp;&nbsp;&nbsp;=&nbsp;&nbsp;&nbsp; MyValue";

And the non-breakable space is not interpreted -- it is entered into the
string literally. Is there a way to enter this character into a string?
Perhaps by hex value? Or is there some other way I can create spacing to
line up the equals signs so it looks good to users?

Thanks!

Hal
Jul 20 '05 #1
2 3448
Fox


Hal Vaughan wrote:

I have a list of variables and values (merge fields for a merge program) and
I want to put them in a list in a <SELECT> object. I'd like them to be
lined up, with an "=" midway between the field and the value. I was going
to fill the space between with spaces, but I noticed a number of spaces are
condensed to one (like in all other parts of HTML). I tried filling it
with non-breakable spaces, like this:

var line = "MyMergeField&nbsp;&nbsp;&nbsp;=&nbsp;&nbsp;&nbsp; MyValue";
var nbsp = String.fromCharCode(160);

line = nbsp + nbsp + MyValue;

And the non-breakable space is not interpreted -- it is entered into the
string literally. Is there a way to enter this character into a string?
Perhaps by hex value? Or is there some other way I can create spacing to
line up the equals signs so it looks good to users?
different fonts have differing spacing characteristics (no telling what
the user has set up) -- you might want to "force" a monospace font for
the style of the select.

I think Andale Mono will work, as will Courier New, but always fall back
on the generic "monospace" to make sure.
Thanks!

Hal

Jul 20 '05 #2
Fox wrote:


Hal Vaughan wrote:

I have a list of variables and values (merge fields for a merge program)
and
I want to put them in a list in a <SELECT> object. I'd like them to be
lined up, with an "=" midway between the field and the value. I was
going to fill the space between with spaces, but I noticed a number of
spaces are
condensed to one (like in all other parts of HTML). I tried filling it
with non-breakable spaces, like this:

var line = "MyMergeField&nbsp;&nbsp;&nbsp;=&nbsp;&nbsp;&nbsp; MyValue";
var nbsp = String.fromCharCode(160);

line = nbsp + nbsp + MyValue;


Thanks -- exactly what I needed!

And the non-breakable space is not interpreted -- it is entered into the
string literally. Is there a way to enter this character into a string?
Perhaps by hex value? Or is there some other way I can create spacing to
line up the equals signs so it looks good to users?


different fonts have differing spacing characteristics (no telling what
the user has set up) -- you might want to "force" a monospace font for
the style of the select.

I think Andale Mono will work, as will Courier New, but always fall back
on the generic "monospace" to make sure.


I already set that up, since the rest of my page is in Arial.
Thanks for the help!

Hal
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Alicia Haumann | last post: by
2 posts views Thread by Roose | last post: by
reply views Thread by Peter Jakubik | last post: by
3 posts views Thread by Gérard Talbot | last post: by
3 posts views Thread by Marco Meoni | last post: by
6 posts views Thread by mistabean | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.