各位高高手,求救阿~~~字符串问题!!!!!!!!

bigbigbear 2002-10-25 04:38:11
各位高高手,求救阿~~~字符串问题!!!!!!!!
本人正在写一主页,需要从库中调出字符显示在主页(动态),可是如果字符串太长会影响页面效果,所以想对从数据库中调出的字符串进行处理,效果如本站主页左边栏的效果,把多余的字符用省略号代替。
以下是我的代码,可是不起作用,请问怎么解决?谢谢
<%
temp=rs(0)
l=len(temp)
if l>2 then
temp=mid(temp,0,2)
temp=temp+"..."
end if
response.write "<a href=detail.asp?mc="&rs(0)&"target=_blank>"&temp&"</a>"
%>
...全文
22 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
bigbigbear 2002-10-25
  • 打赏
  • 举报
回复
大家的都对,我把mid函数的起始位搞错了~~~应该是1,哈哈~~谢谢关注,结帖了~~
mytd 2002-10-25
  • 打赏
  • 举报
回复
yes
liuqinyi 2002-10-25
  • 打赏
  • 举报
回复
好像大同小意了。呵呵;)他们的好像都可以。
huangyq 2002-10-25
  • 打赏
  • 举报
回复
试试这样:
<%
temp=rs(0)
l=len(temp)
if len(rs(0)) > 2 then
temp=left(rs(0),2)
temp=temp+"..."
else
temp=rs(0)
end if
%>
hainan 2002-10-25
  • 打赏
  • 举报
回复
<%
temp=rs(0)
l=len(temp)
if l>2 then
temp=left(temp,2)
temp=temp+"..."
end if
response.write "<a href=detail.asp?mc="&rs(0)&"target=_blank>"&temp&"</a>"
%>
denghan 2002-10-25
  • 打赏
  • 举报
回复
这样做
假设你取字符串的字段为title
<% if len(rs("title")) > 30 then
response.write left(rs("title"),30)&"..."
else
resopnse.write rs("title")
end if
%>

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧