在对齐的列中显示数字 [英] Displaying numbers in aligned columns

查看:64
本文介绍了在对齐的列中显示数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过以下内容,我试图显示numberOne和numberTwo,每个都是两位数的字符

组,例如nn。如果numberOne或numberTwo小于10,则bn为bn。将显示(其中b

是空格字符)。换句话说,我总是希望每个数字的第二个数字位于

相同的列中,以便restOfText的开头。将从每个记录的同一列开始

由以下代码生成。


我尝试了几件事,但似乎无法拿出答案。任何帮助将是

赞赏。

var numberOne = numberOne.toString();

if(numberOne.length == 1)

numberOne =" + numberOne;


var numberTwo = numberTwo.toString();

if(numberTwo.length == 1)

numberTwo = " + numberTwo;

var htmlString =''< font face =" Arial"大小= QUOT; 2英寸color ="#0000FF">''+ numberOne +''< font

color ="#FF0000">''+ numbertwo +''< / font>< / font>''+ restOfText;

谢谢,

Don


---- ==发表于Newsfeeds.Com - 无限制 - 未经审查 - 安全使用网新闻== ----
http:// www。 newsfeeds.com 世界排名第一的新闻组服务! 120,000多个新闻组

---- =东海岸和西海岸服务器农场 - 通过加密实现全隐私= ----

With the following, I''m trying to display numberOne and numberTwo, each as a two digit character
group, such as "nn". If numberOne or numberTwo is less than 10, "bn" will be displayed (where "b"
is a space character). In other words, I always want the second digit of each number to be in the
same column, so that the beginning of "restOfText" will start in the same column for each record
produced by the following code.

I''ve tried several things, but can''t seem to come up with the answer. Any help would be
appreciated.
var numberOne = numberOne.toString();
if(numberOne.length == 1)
numberOne = " "+numberOne;

var numberTwo = numberTwo.toString();
if(numberTwo.length == 1)
numberTwo = " "+numberTwo;
var htmlString = ''<font face="Arial" size="2" color="#0000FF">'' + numberOne + ''<font
color="#FF0000">'' + numbertwo + ''</font></font>'' + restOfText;
Thanks,
Don

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

推荐答案

2005年3月8日星期二11:55:54 -0700,Don< no@adr.com>写道:
On Tue, 08 Mar 2005 11:55:54 -0700, Don <no@adr.com> wrote:
以下,我试图显示numberOne和numberTwo,每个都是一个两位数的字符组,例如nn。如果numberOne或numberTwo小于10,则bn为bn。将显示(其中b
是空格字符)。换句话说,我总是希望每个数字的第二个数字在同一列中,以便restOfText的开头。将从以下代码生成的每个记录的同一列开始。

我已经尝试了几件事,但似乎无法得出答案。任何帮助都将受到赞赏。

var numberOne = numberOne.toString();
if(numberOne.length == 1)
numberOne =" + numberOne;

var numberTwo = numberTwo.toString();
if(numberTwo.length == 1)
numberTwo =" " + numberTwo;

var htmlString =''< font face =" Arial"大小= QUOT; 2英寸color ="#0000FF">''+ numberOne +''< font
color ="#FF0000">''+ numbertwo +''< / font>< / font>' '+ restOfText;

谢谢,
Don

---- ==通过Newsfeeds.Com发布 - 无限制 - 未经审查 - 安全Usenet新闻== - -
http://www.newsfeeds.com #1新闻组服务在世界上! 120,000多个新闻组
---- =东海岸和西海岸服务器农场 - 通过加密的总隐私= ----
With the following, I''m trying to display numberOne and numberTwo, each as a two digit character
group, such as "nn". If numberOne or numberTwo is less than 10, "bn" will be displayed (where "b"
is a space character). In other words, I always want the second digit of each number to be in the
same column, so that the beginning of "restOfText" will start in the same column for each record
produced by the following code.

I''ve tried several things, but can''t seem to come up with the answer. Any help would be
appreciated.
var numberOne = numberOne.toString();
if(numberOne.length == 1)
numberOne = " "+numberOne;

var numberTwo = numberTwo.toString();
if(numberTwo.length == 1)
numberTwo = " "+numberTwo;
var htmlString = ''<font face="Arial" size="2" color="#0000FF">'' + numberOne + ''<font
color="#FF0000">'' + numbertwo + ''</font></font>'' + restOfText;
Thanks,
Don

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----



顺便说一句,restOfText被设置为以Verdana显示。字体(比例字体)。我正在展示

" numberOne"和numberTwo在Arial中(单行间距字体)。


Don


---- ==通过Newsfeeds.Com发布 - 无限制 - 未经审查 - 安全使用网新闻== ----
http://www.newsfeeds.com 世界排名第一的新闻组服务! 120,000多个新闻组

---- =东海岸和西海岸服务器农场 - 通过加密实现全隐私= ----


By the way, "restOfText" is setup to display in "Verdana" font (proportional font). I''m displaying
"numberOne" and "numberTwo" in "Arial" (mono-spaced font).

Don

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----


Don写道:
使用以下内容,我试图将numberOne和numberTwo,
各自显示为两位数的字符组,例如nn。如果numberOne或numberTwo小于10,则
bn将显示(其中b是空格字符)。换句话说,我总是希望每个数字的第二个
数字在同一列中,以便restOfText的开头。将从以下代码生成的每条记录的
相同列开始。

我已经尝试了几件事,但似乎无法得出答案。
任何帮助都将不胜感激。

var numberOne = numberOne.toString();
if(numberOne.length == 1)
numberOne =" + numberOne;

var numberTwo = numberTwo.toString();
if(numberTwo.length == 1)
numberTwo =" " + numberTwo;

var htmlString =''< font face =" Arial"大小= QUOT; 2英寸color ="#0000FF">''+
numberOne +''< font color ="#FF0000">''+ numbertwo +''< / font>< / font>' '+ restOfText;

谢谢,
Don
With the following, I''m trying to display numberOne and numberTwo, each as a two digit character group, such as "nn". If numberOne or numberTwo is less than 10, "bn" will be displayed (where "b" is a space character). In other words, I always want the second digit of each number to be in the same column, so that the beginning of "restOfText" will start in the same column for each record produced by the following code.

I''ve tried several things, but can''t seem to come up with the answer. Any help would be appreciated.
var numberOne = numberOne.toString();
if(numberOne.length == 1)
numberOne = " "+numberOne;

var numberTwo = numberTwo.toString();
if(numberTwo.length == 1)
numberTwo = " "+numberTwo;
var htmlString = ''<font face="Arial" size="2" color="#0000FF">'' + numberOne + ''<font color="#FF0000">'' + numbertwo + ''</font></font>'' + restOfText;
Thanks,
Don




< font>标签在很久以前就已被弃用。这实际上是一个布局

(HTML / CSS)问题,因为你没有给出任何细节

与页面设置方式有关,所以无法回答。 ''列''表示一个表,而你

可以使用CSS''text-align''对数据进行右对齐。



The <font> tag was deprecated ages ago. This is really a layout
(HTML/CSS) question, impossible to answer as you''ve given no details
relating to how the page is set up. ''column'' suggests a table, and you
can use CSS ''text-align'' to right-justify data.

Don于2005年8月在comp.lang.javascript中写道
Don wrote on 08 mrt 2005 in comp.lang.javascript:
var numberOne = numberOne.toString();
if (numberOne.length == 1)
numberOne =" " + numberOne;
var numberOne = numberOne.toString();
if(numberOne.length == 1)
numberOne = " "+numberOne;




函数TwoPlacesAtLeast(x){

return((x +''')。length == 1) ?''& nbsp;''+ x:''''+ x

}


sp1 =''< span style =" font-family:courier;">''

sp2 =''< / span>< br>''

document.write (sp1 + TwoPlacesAtLeast(1)+ sp2);

document.write(sp1 + TwoPlacesAtLeast(12)+ sp2);

document.write(sp1 + TwoPlacesAtLeast(3) )+ sp2);

document.write(sp1 + TwoPlacesAtLeast(99)+ sp2);


-

Evertjan 。

荷兰。

(用我的电子邮件地址替换所有带点的十字架)



function TwoPlacesAtLeast(x){
return ((x+'''').length==1)?''&nbsp;''+x:''''+x
}

sp1 = ''<span style="font-family:courier;">''
sp2 = ''</span><br>''

document.write(sp1+TwoPlacesAtLeast(1)+sp2);
document.write(sp1+TwoPlacesAtLeast(12)+sp2);
document.write(sp1+TwoPlacesAtLeast(3)+sp2);
document.write(sp1+TwoPlacesAtLeast(99)+sp2);

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)


这篇关于在对齐的列中显示数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆