日期:2014-05-17  浏览次数:21025 次

怎么给前三条信息的标题后面加new图标?
我的部分代码如下:
If Not rs.eof or not rs.bof Then
  Do While Not rs.eof  
  if len(rs("title_xl")) > 18 then '判断字符串的长度  
  %>
  <tr>
  <td width="30" class="jiage" align="center"><img src="Images/in_5.gif" width="10" height="10"></td>
  <td width="611" class="jiage"><a href='qyxw_view.asp?hid=<%=rs("id_xl")%>' class="link"><%=left(rs("title_xl"),17)%></a></td>
  </tr><%
else
  %>
  <tr>
  <td width="30" class="jiage" align="center"><img src="Images/in_5.gif" width="10" height="10"></td>
  <td width="611" class="jiage"><a href='qyxw_view.asp?hid=<%=rs("id_xl")%>' class="link"><%=rs("title_xl")%> </a></td>
  </tr>
  <%
end if
rs.movenext
Loop
else
  %>
  <font>&nbsp;暂无信息</font>
  <%
End If  
rs.close
  set rs=nothing

  %>
title_xl是信息的标题,我想要在前三条信息后加new图标代码要怎么写? 


------解决方案--------------------
不用判断标题长度啊,if else语句可以去掉了
HTML code
<%
If Not rs.eof or not rs.bof Then
  idx=1
  Do While Not rs.eof  
  %>
  <tr>
  <td width="30" class="jiage" align="center"><img src="Images/in_5.gif" width="10" height="10"></td>
  <td width="611" class="jiage"><a href='qyxw_view.asp?hid=<%=rs("id_xl")%>' class="link"><%=left(rs("title_xl"),17)%></a><%if idx<4 then response.write "<img src='new图片路径'/>"%></td>
  </tr>
rs.movenext
idx=idx+1
Loop
else
  %>
  <font>&nbsp;暂无信息</font>
  <%
End If  
rs.close
  set rs=nothing

  %>

------解决方案--------------------
1.强烈建议不要截取字符,使用css来隐藏多余字符。
2.代码写工整点
VB code

<%
If Not rs.eof or not rs.bof Then
    i=0
    Do While Not rs.eof
        i=i+1
        Response.write "<tr><td width='30' class='jiage' align='center'><img src='Images/in_5.gif' width='10' height='10'></td>"
        Response.write "<td width='611' class='jiage'><a href='qyxw_view.asp?hid="&rs("id_xl")&"' class='link'>"&rs("title_xl")&"</a>"
        if i<4 then Response.write "<img src='Images/news.gif' width='10' height='10'>" '最新图标
        Response.write "</td></tr>"&vbcrlf
        rs.movenext
    Loop
else
    Response.write "暂无信息"
End If
rs.close
set rs=nothing
%>

<style type="text/css">
    .link{
        display: inline-block;
        width:600px;/*调整宽度*/
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
</style>