在我的下拉菜单中对齐文字? [英] Align text in my drop down menu?

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

问题描述

大家好,

我从数据库获取记录并通过asp页面的下拉菜单向用户显示记录




每条记录有6个字段,我需要将所有字段全部显示给用户

下拉。


问题是字段包含所有不同长度的值

并且列未对齐。


我试图通过计算每个字段和填充的len来对齐但

这些字符的宽度不同,这不起作用。


有人能告诉我如何在下拉菜单中对齐文字吗?我会

感谢那里的任何想法。


非常感谢你的帮助,

-Dan

解决方案

您可以使用& nbsp;''将值填充到最小长度,并使用

固定宽度字体,如此:


<%

功能PadTo(theString,theLength)

''''''取一个字符串和一个最小长度

'''''为字符串填充字符串

''''''& nbsp;'s,然后返回字符串

'''''指定的长度

PadTo =替换(左(TheString& String(theLength,"),theLength),"

","& nbsp;")

结束功能


Dim aData(5,2)


aData(0,0)=" Ray"

aData(1,0)=" Costanzo"

aData (2,0)=" 123 Some RD"

aData(3,0)=" Somecity&qu ot;

aData(4,0)=" ZZ"

aData(5,0)=" 99999"

aData( 0,1)=" Joe"

aData(1,1)=" Smith"

aData(2,1)=" 987 Other Rd"

aData(3,1)=" Another City"

aData(4,1)=" AA"

aData(5, 1)=" 88888"

aData(0,2)=" Betty"

aData(1,2)=" Jones"

aData(2,2)=" 456 Main St"

aData(3,2)=" Anytown"

aData(4,2)= QQ

aData(5,2)=" 77777"


%>

< select style =" font-family:monospace;">

<%

For i = 0 To UBound(aData,2)

sPadded = PadTo(aData(0,i),10)& PadTo(aData(1,i),20)&

PadTo(aData(2,i),25)& PadTo(aData(3,i),25)& PadTo(aData(4,i),4)&

PadTo(aData(5,i),10)

Response.Write"< option value = "" yourValue"">" &安培; sPadded& "< /选项>" &

vbCrLf

下一页

%>

< / select>

雷在工作

丹 <哒*********** @ dbt.net>在消息中写道

news:f0 ************************** @ posting.google.c om ...

大家好,
我从数据库中获取记录,并通过asp页面的下拉菜单向用户显示记录。
每个记录有6个字段,我需要在下拉列表中将它们全部显示给用户。

问题是这些字段包含所有不同长度的值
和列没有对齐。

我试图通过计算每个字段和填充的len来对齐,但
字符是不同的宽度,这不起作用。
有人可以告诉我如何在下拉列表中对齐文本吗?我会感谢那里的任何想法。

非常感谢你的帮助,
-Dan



< blockquote>你有没有尝试过CSS?


" Dan" <哒*********** @ dbt.net>在消息中写道

news:f0 ************************** @ posting.google.c om ...

大家好,
我从数据库中获取记录,并通过asp页面的下拉菜单向用户显示记录。
每个记录有6个字段,我需要在下拉列表中将它们全部显示给用户。

问题是这些字段包含所有不同长度的值
和列没有对齐。

我试图通过计算每个字段和填充的len来对齐,但
字符是不同的宽度,这不起作用。
有人可以告诉我如何在下拉列表中对齐文本吗?我会感谢那里的任何想法。

非常感谢你的帮助,
-Dan



---

外发邮件经过无病毒认证。

由AVG反病毒系统检查( http://www.grisoft.com)

版本:6.0.781 /病毒库:527 - 发布日期:2004年10月21日


谢谢Ray。我在我的

之前的帖子中提到了我的确切建议,但问题是字符串可能是相同的

长度,但html页面的宽度不同。


无论如何,我发布了下面的问题代码以进行更改。感谢

你。


<选项>< B>

<%Response.Write(ld)%> ;

<%Response.Write(id)%>

<%Response.Write(appname)%>

< ;%Response.Write(transdesc)%>

<%Response.Write(referenceid)%>

<%Response.Write(transid)%> ;

<%Response.Write(transamount)%>

< / option>

" Ray Costanzo [MVP]" ; <我的第34号商业广告的名字>在消息新闻中写道:< #P ************** @ TK2MSFTNGP12.phx.gbl> ...

您可以将值填充到最小长度使用& nbsp;并使用
固定宽度字体,如下所示:

<%
功能PadTo(theString,theLength)
'' ''''取一根绳子和一根最小长度
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''在theLength指定的字符串
''''''
PadTo =替换(左(TheString& String(theLength,")),theLength),
, "& nbsp;")
结束功能

昏暗的aData(5,2)
aData(0,0)=" Ray"
aData(1,0)=" Costanzo"
aData(2,0)=" 123 Some RD"
aData(3,0)=" Somecity"
aData(4,0)=" ZZ"
aData(5,0)=" 99999"
aData(0,1)=" Joe"
aData(1,1 ) =" Smith"
aData(2,1)=" 987 Other Rd"
aData(3,1)=" Another City"
aData(4,1)=" ; AA"
aData(5,1)=" 88888"
aData(0,2)=" Betty"
aData(1,2)=" Jones"
aData(2,2)=" 456 Main St"
aData(3,2)=" Anytown"
aData(4,2)=" QQ"
aData (5,2)=" 77777"

%>

< select style =" font-family:monospace;">
<%
对于i = 0到UBound(aData,2)
sPadded = PadTo(aData(0,i),10)& PadTo(aData(1,i),20)&
PadTo(aData(2,i),25)& PadTo(aData(3,i),25)& PadTo(aData(4,i),4)&
PadTo(aData(5,i),10)
Response.Write"< option value ="" yourValue"" >" &安培; sPadded& "< /选项>" &
vbCrLf
下一页
%>
< / select>

Ray at work

Dan ; <哒*********** @ dbt.net>在消息中写道
新闻:f0 ************************** @ posting.google.c om ...

大家好,
我从数据库中获取记录,并通过asp页面的下拉菜单向用户显示记录。

每条记录都有6个字段,我需要在下拉列表中将它们全部显示给用户。

问题是字段包含所有不同长度的值
而列不是对齐。

我尝试通过计算每个字段和填充的len来对齐但是
字符是不同的宽度,这不起作用。

有人可以告诉我如何在下拉列表中对齐文本?我会感谢那里的任何想法。

非常感谢你的帮助,
-Dan



Hello all,
I am getting records from a db and displaying the records to the user
through a drop down menu in an asp page.

Each record has 6 fields and I need to display them all to the user in
the drop down.

The problem is that the fields contain values of all different lengths
and the columns are not aligned.

I tried to align by calculating the len for each field and padding but
the characters are different widths and this does not work.

Can someone tell me how to align the text in the drop down? I would
appreciate any ideas out there.

Thank you much for your help,
-Dan

解决方案

You could pad your values to a minimum length with &nbsp;''s and use a
fixed-width font like so:

<%
Function PadTo(theString, theLength)
''''''Take a string and a mininum length
''''''for the string, pads the string with
''''''&nbsp;''s, and then returns the string
''''''at theLength specified
PadTo = Replace(Left(TheString & String(theLength, " "), theLength), "
", "&nbsp;")
End Function

Dim aData(5,2)

aData(0,0) = "Ray"
aData(1,0) = "Costanzo"
aData(2,0) = "123 Some RD"
aData(3,0) = "Somecity"
aData(4,0) = "ZZ"
aData(5,0) = "99999"
aData(0,1) = "Joe"
aData(1,1) = "Smith"
aData(2,1) = "987 Other Rd"
aData(3,1) = "Another City"
aData(4,1) = "AA"
aData(5,1) = "88888"
aData(0,2) = "Betty"
aData(1,2) = "Jones"
aData(2,2) = "456 Main St"
aData(3,2) = "Anytown"
aData(4,2) = "QQ"
aData(5,2) = "77777"

%>
<select style="font-family: monospace;">
<%
For i = 0 To UBound(aData, 2)
sPadded = PadTo(aData(0,i), 10) & PadTo(aData(1,i), 20) &
PadTo(aData(2,i), 25) & PadTo(aData(3,i), 25) & PadTo(aData(4,i), 4) &
PadTo(aData(5,i), 10)
Response.Write "<option value=""yourValue"">" & sPadded & "</option>" &
vbCrLf
Next
%>
</select>
Ray at work
"Dan" <da***********@dbt.net> wrote in message
news:f0**************************@posting.google.c om...

Hello all,
I am getting records from a db and displaying the records to the user
through a drop down menu in an asp page.

Each record has 6 fields and I need to display them all to the user in
the drop down.

The problem is that the fields contain values of all different lengths
and the columns are not aligned.

I tried to align by calculating the len for each field and padding but
the characters are different widths and this does not work.

Can someone tell me how to align the text in the drop down? I would
appreciate any ideas out there.

Thank you much for your help,
-Dan



Have you tried CSS ??

"Dan" <da***********@dbt.net> wrote in message
news:f0**************************@posting.google.c om...

Hello all,
I am getting records from a db and displaying the records to the user
through a drop down menu in an asp page.

Each record has 6 fields and I need to display them all to the user in
the drop down.

The problem is that the fields contain values of all different lengths
and the columns are not aligned.

I tried to align by calculating the len for each field and padding but
the characters are different widths and this does not work.

Can someone tell me how to align the text in the drop down? I would
appreciate any ideas out there.

Thank you much for your help,
-Dan


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.781 / Virus Database: 527 - Release Date: 10/21/2004


Thank you Ray. I tried exactly your suggestion as I mentioned in my
previous posting but the problem is that the strings may be the same
length but the widths are different on the html page.

Anyway I am posting the problem code below for clerification. Thank
you.

<option><B>
<%Response.Write(ld)%>
<%Response.Write(id)%>
<%Response.Write(appname)%>
<%Response.Write(transdesc)%>
<%Response.Write(referenceid)%>
<%Response.Write(transid)%>
<%Response.Write(transamount)%>
</option>
"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in message news:<#P**************@TK2MSFTNGP12.phx.gbl>...

You could pad your values to a minimum length with &nbsp;''s and use a
fixed-width font like so:

<%
Function PadTo(theString, theLength)
''''''Take a string and a mininum length
''''''for the string, pads the string with
''''''&nbsp;''s, and then returns the string
''''''at theLength specified
PadTo = Replace(Left(TheString & String(theLength, " "), theLength), "
", "&nbsp;")
End Function

Dim aData(5,2)

aData(0,0) = "Ray"
aData(1,0) = "Costanzo"
aData(2,0) = "123 Some RD"
aData(3,0) = "Somecity"
aData(4,0) = "ZZ"
aData(5,0) = "99999"
aData(0,1) = "Joe"
aData(1,1) = "Smith"
aData(2,1) = "987 Other Rd"
aData(3,1) = "Another City"
aData(4,1) = "AA"
aData(5,1) = "88888"
aData(0,2) = "Betty"
aData(1,2) = "Jones"
aData(2,2) = "456 Main St"
aData(3,2) = "Anytown"
aData(4,2) = "QQ"
aData(5,2) = "77777"

%>
<select style="font-family: monospace;">
<%
For i = 0 To UBound(aData, 2)
sPadded = PadTo(aData(0,i), 10) & PadTo(aData(1,i), 20) &
PadTo(aData(2,i), 25) & PadTo(aData(3,i), 25) & PadTo(aData(4,i), 4) &
PadTo(aData(5,i), 10)
Response.Write "<option value=""yourValue"">" & sPadded & "</option>" &
vbCrLf
Next
%>
</select>
Ray at work
"Dan" <da***********@dbt.net> wrote in message
news:f0**************************@posting.google.c om...

Hello all,
I am getting records from a db and displaying the records to the user
through a drop down menu in an asp page.

Each record has 6 fields and I need to display them all to the user in
the drop down.

The problem is that the fields contain values of all different lengths
and the columns are not aligned.

I tried to align by calculating the len for each field and padding but
the characters are different widths and this does not work.

Can someone tell me how to align the text in the drop down? I would
appreciate any ideas out there.

Thank you much for your help,
-Dan



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

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