简体   繁体   English

如何显示2列下拉列表ASP经典

[英]How to display 2 column Dropdown List ASP classic

I am currently transforming systems that was made in MS Access and I am reprogramming all web based using ASP classic. 我目前正在转换MS Access中制成的系统,并且正在使用ASP classic重新编程所有基于Web的程序。 I'm in a little snag and I really looked all over the web for this for the passed 2 days and no luck. 我有点sn,在过去的两天里,我确实在网上浏览了整个过程,但没有运气。

What I am trying to accomplish is a drop down list that as 3 simple column like the current systems in Access so say I am looking for the follow output in the HTML select list. 我想要完成的是一个下拉列表,它像Access中的当前系统一样为3个简单列,因此我正在HTML选择列表中寻找follow输出。

Choose a company 选择公司

walmart         25 street Montreal 
crazy man       36 bad street Laval
bad company     36 ethos street app 32 Quebec 
hello world     36 apples Toronto

This output comes from a SQL Server database. 此输出来自SQL Server数据库。

I tried the following: counting how much characters are in the company name (say..20 chars), then I want to add equal spaces to the company name so say (100 chars). 我尝试了以下操作:计算公司名称中有多少个字符(例如20个字符),然后我想在公司名称中添加相等的空格,例如100个字符。

In this case I will would take the amount (100-20) and add this the the company name then take the name of the company and join it to the address and town. 在这种情况下,我将取金额(100-20),并将其添加到公司名称中,然后获取公司名称,并将其加入地址和城镇。

Each time I go through the loop I redo the calculation. 每次循环时,我都会重做计算。

This is all done in asp classic here is the code 这一切都是在asp classic中完成的,这里是代码

<select id="search_Comp" name="search_Comp">
<option value="0">---</option>
<%
'loop
while not RS.EOF

'check if the company name is smaller than 100 characters
if len(RS("Comp_Name")) < 100 then

 'calculation of the padding
  whiteSpaceSize = 100 - len(RS("Comp_Name"))

end if 

'create the spaces need
nameCompSP = space(whiteSpaceSize)

'add the spaces to the company name  
nameComp = trim(RS("Comp_Name")) & nameCompSP

'replace for spaces for html output
NnameComp = replace(nameComp," ","&nbsp;")


%>
<option value="<%= trim(RS("Comp_ID"))%>"><%=NnameComp %><%= trim(RS("Comp_CAdd1"))%></option>
<%
RS.MOVENEXT
wend 
%>
</select>

this outputs the spaces but they still don't line up ! 这将输出空格,但它们仍未对齐!

I tried with SQL too but didn't work 我也尝试过SQL但没有用

-- here is the query example --
SELECT 
    Comp_Name + SPACE (100 – len(Comp_Name)) + Comp_CAdd1 AS Comp_Name 
FROM 
    company
/****address will always be 100 char way from the first char of Company, the space in between padded with spaces ***/

but still outputs the columns with spaces but don't line up... 但仍输出带有空格的列,但不对齐...

Can someone help me with this? 有人可以帮我弄这个吗? I am not finding anything and no info in google and forums - let me know please really appreciated... 我在Google和论坛中找不到任何内容,也没有任何信息-请让我知道,非常感谢...

K3v_n K3v_n

Because the default font used is proportional, they'll never line up. 因为使用的默认字体是成比例的,所以它们永远不会对齐。 You need to use a monospaced font. 您需要使用等宽字体。

in your stylesheet, use: 在样式表中,使用:

select {
    font-family:courier;
    font-size:14px;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM