首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

如何给前三条信息的标题后面加new图标

2012-08-24 
怎么给前三条信息的标题后面加new图标?我的部分代码如下:If Not rs.eof or not rs.bof ThenDo While Not r

怎么给前三条信息的标题后面加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.movenextidx=idx+1Loopelse  %>  <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    Loopelse    Response.write "暂无信息"End Ifrs.closeset rs=nothing%><style type="text/css">    .link{        display: inline-block;        width:600px;/*调整宽度*/        overflow: hidden;        text-overflow: ellipsis;        white-space: nowrap;    }</style> 

热点排行