By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,712 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,712 IT Pros & Developers. It's quick & easy.

Embedding Non-Breakable Spaces into Strings -- How?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.