注册 登录
编程论坛 ASP技术论坛

关于asp调用文字超出使用...代替

hn3326 发布于 2010-05-12 00:33, 619 次点击
代码如下
<a href="ShowDetail.asp?type=Article&id=<%=rs("id")%>" target="_blank"><%if rs("titlecolor")<>"" then%><font style="color:<%=rs("titlecolor")%>;"><%=Left(rs("title"),15)%></font><%else response.Write(mid(rs("title"),1,25))
        response.write ("...") end if%></a><span>[<%=rs("posttime")%>]</span></li>
        <%
            rs.movenext
            next
        end if
        %>

我使用
><%else response.Write(mid(rs("title"),1,25))
        response.write ("...") end if%>
之后发现每行都有... 了 怎么让超出标题27 后剩下的表示...
3 回复
#2
hn33262010-05-12 01:34
比如  标题为
从“渴望出名”到为社会奉献:共同创造调查揭示市场对亚洲青年的误读
20世纪最成功的100个广告战役

表示为
从“渴望出名”到为社会奉献:共同创造调查揭示市场对...
20世纪最成功的100个广告战役

不需要全部表示为
从“渴望出名”到为社会奉献:共同创造调查揭示市场对...
20世纪最成功的100个广告战役...
#3
hams2010-05-12 08:52


<a href="ShowDetail.asp?type=Article&id=<%=rs("id")%>" target="_blank">
<%if rs("titlecolor")<>"" then%>
     <font style="color:<%=rs("titlecolor")%>;"><%=Left(rs("title"),15)%></font>
<%else
     response.Write(mid(rs("title"),1,25))
     if len(rs("title"))>25 then response.write ("...")
end if%></a><span>[<%=rs("posttime")%>]</span></li>
        <%
            rs.movenext
            next
        end if
        %>
#4
gupiao1752010-05-12 10:46
以下是引用hams在2010-5-12 08:52:03的发言:



<%=rs("id")%>" target="_blank">
<%if rs("titlecolor")<>"" then%>
     <%=rs("titlecolor")%>;"><%=Left(rs("title"),15)%>
<%else
     response.Write(mid(rs("title"),1,25))
     if len(rs("title"))>25 then response.write ("...")
end if%>[<%=rs("posttime")%>]
        <%
            rs.movenext
            next
        end if
        %>
正解,核心用到了len进行判断其长度,如果超过长度就截取,不超过就直接显示!
1