驱魔人精校版:asp如何实现这种效果?

来源:百度文库 编辑:高考问答 时间:2024/05/01 04:06:37
首页调取数据库栏目标题,我设置只显示标题的前10个字符,如何实现多于10个字的标题后面用...显示,而不到10个字的标题没有...?

<%
if len(rs("字段")) >10 then
response.Write(left(rs("字段"),10)&"......")
else
response.Write(rs("字段"))
end if

%>

<%
function GetShortStr(srcstr,desclen)
charlen=0
for i=1 to len(srcstr)
char=Abs(Asc(Mid(srcstr,i,1)))
if char>255 then
charlen=charlen+2
else
charlen=charlen+1
end if
if charlen>=desclen then
GetShortStr=left(srcstr,i)&".."
exit for
else
GetShortStr=srcstr&" "
end if
next
end function
response.write GetShortStr("你要显示的内容",10)
%>