繁体   English   中英

如何在经典ASP中以html表格式显示内容

[英]how to display content in html table format in Classic ASP

试图显示将由bAddItem()在输出中并排添加的2个项目。我尝试使用HTML标签,但未能成功,我也曾在response.write()中使用HTML标签,但失败了,有人可以建议如何在输出中并排显示文本和复选框

<%  
for iCount = 0 to UBound(aPhoneTypeId,2) - 1
dim Consentindarray
dim Checkedstatus
dim consentvalue
Consentindarray=""
Checkedstatus=0
Consentindarray = split(TrimValue(oRstInd("user48")),",") 
for each consentvalue in Consentindarray
   if InStr(1, consentvalue, trim(aPhoneTypeId(0,iCount)) ) > 0 then
        Checkedstatus=1              
   end if
next
if Len(trim(aPhone(iCount))) > 0 then
   if aPhoneTypeId(0,icount) = sPhoneType then 
       **if bSuccess then bSuccess = bAddItem(oSectionNode, "text", aPhoneTypeId(1,icount), aPhone(iCount), "", true)**  end if

       **if bSuccess then bSuccess = bAddItem(oSectionNode, "checkbox","",Checkedstatus, "", false)** end if

   else 
     if bSuccess then bSuccess = bAddItem(oSectionNode, "text", aPhoneTypeId(1,icount), aPhone(iCount), "", false) end if

     if bSuccess then bSuccess = bAddItem(oSectionNode, "checkbox","",Checkedstatus, "", false) end if

   end if
  end if
next 

您以与其他任何html相同的方式输出表:使用Response.Write语句,或使用%>关闭脚本,然后编写实际的html。

 <html>
 <head><title>This is my page</title>
 <%
 dim V, N, i
 %>
 </head>
 <body>
 <table><tr><th>Name</th><th>Age</th></tr>
 <%
 ' ... (code to load data into V() goes here)
 ' ...
 If N = 0 Then 
    Response.Write "<tr><td colspan='2'>No data found</td></tr>"
 Else
    For i = 0 to N-1
       Response.Write "<tr><td>" & V(0,i) & "</td><td>" & V(1,i) & "</td></tr>"
    Next
 End If
 %>
 </table>
 </body>
 </html>

我对引号值采取了“简便的方法”:我只使用单引号,因为html不在乎。 如果必须使用双引号,则可以选择双引号( "<td colspan=""2"">" )或使用字符代码:( "<td colspan=" & Chr(34) & "2" & Chr(34) & ">" )。

就是说,看起来您没有输出任何表格形式的内容。 据我所知,您似乎正在尝试写出一个复选框和一个标签。 其机制实际上没有任何不同。 您只需要使用适当的html标签即可。 (不过有一件事:首先拥有复选框,然后再带有标签几乎总是更好的做法,这是大多数人习惯的做法,如果您具有复选框列表,那么对齐方式会更好。)

...
<form method="post" action="FormName.asp">
<input type="hidden" name="Option1" value="<%=Opt1%>">
<%
For f = 1 to iCount
   Response.Write "<p><label><input type='checkbox'"
   Response.Write " value='" & aPhoneTypeId(0,f) & "'"
   Response.Write " name='PhoneType_" & f & "'"
   If aPhoneTypeId(0,f) = sPhoneType Then Response.Write " checked"
   Response.Write ">" & aPhoneTypeId(1,f) & "</label></p>"
Next
%>
</form>
...

(请注意,我不知道您的变量实际包含什么,因此上面的内容可能很乱,但是它应该为您提供入门提示。)

暂无
暂无

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

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