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

我想问一下,这句程序要怎么样写?

小丁丁 发布于 2008-06-05 15:11, 803 次点击
在页面的顶部,我定义了这个
<%
function chklon(str,l)
if len(str)>l then
str=mid(str,1,l)&"……"
end if
chklon=str
end function
%>
然后我在下面这行要输出
<%
     set rs=server.createobject("adodb.recordset")               
      sql="select title,content from introduce where id=1"                  
      rs.open sql,conn,1,1
      if not rs.eof and not rs.bof then
            content=rs("content")
            title=rs("title")
     end if
     rs.close
     %>

<td><%=title%>br<%=content%></td>

我想控制<%=content%>是显示字数要怎么样写<%=content%>
7 回复
#2
zhangyao32872008-06-05 15:49
方法很多了,asp里最简单的就是
<%
function chklon(str,l)
if len(str)>l then
chklon=left(str,l)
else
chklon=str
end if
end function
%>
<%=chklon(content,"100")%>
#3
小丁丁2008-06-05 17:05
谢你这种方法我试了不行啊,<%=chklon(content,"100")%>这里面有点错误吧,能不能再改下,啊
#4
hmhz2008-06-05 17:55
<%
function chklon(str,l)
if len(str)>l then
chklon=left(str,l)&"……"
else
chklon=str
end if
end function
%>

<%=chklon(content,100)%>

[[it] 本帖最后由 hmhz 于 2008-6-5 17:59 编辑 [/it]]
#5
小丁丁2008-06-06 08:53
恩谢了,这方法能用,多谢~~!!
#6
zhangyao32872008-06-06 09:01
我就少写一个&"......"你就不会用了?我晕了
#7
小丁丁2008-06-06 10:20
呵呵我是刚学的不是太懂,不是因为你没有写&"....."这个,而是"100"这上面多了两个引号.
#8
zhangyao32872008-06-06 10:21
哦,把数据类型写错了啊
嘿嘿
1