<%
set conn=server.CreateObject("adodb.connection")
conn.open="driver={microsoft access driver (*.mdb)};dbq="&server.MapPath("db/#aaa.asp")
set ors=server.CreateObject("Adodb.RecordSet")
osql="select D_id,D_CataID,D_Title from [NewsData] where D_CataID='A0004' order by D_id desc"
ors.open osql,conn,1,1
response.write("<table width='98%' cellspacing=2 class=pt9>")
response.Write("<tr>")
i=1
do while not ors.eof
if i mod 3 = 1 then
response.write "</tr>"
end if
response.write "<td height='18'>·<a href='News/Show.asp?id="&ors("D_id")&"'>"&ors("D_Title") &"</a></td>"
if i mod 3 =0 then
response.write "</tr>"
end if
i = i + 1
ors.movenext
loop
response.write("</table>")
ors.close
set ors=nothing
%>
想限制一下每个标题不超过3个字 请问该怎么改写。
请把完整的代码贴出来,谢谢了,本人小白。只贴一段的不知道该加到哪个位置
求asp限制字数的代码
答案:4 悬赏:0 手机版
解决时间 2021-03-22 22:37
- 提问者网友:贪了杯
- 2021-03-22 08:08
最佳答案
- 五星知识达人网友:舍身薄凉客
- 2021-03-22 09:45
<%
set conn=server.CreateObject("adodb.connection")
conn.open="driver={microsoft access driver (*.mdb)};dbq="&server.MapPath("db/#aaa.asp")
set ors=server.CreateObject("Adodb.RecordSet")
osql="select D_id,D_CataID,D_Title from [NewsData] where D_CataID='A0004' order by D_id desc"
ors.open osql,conn,1,1
response.write("<table width='98%' cellspacing=2 class=pt9>")
response.Write("<tr>")
i=1
do while not ors.eof
if i mod 3 = 1 then
response.write "</tr>"
end if
response.write "<td height='18'>·<a href='News/Show.asp?id="&ors("D_id")&"'>"&left(ors("D_Title"),3) &"</a></td>" '注意这里已被修改
if i mod 3 =0 then
response.write "</tr>"
end if
i = i + 1
ors.movenext
loop
response.write("</table>")
ors.close
set ors=nothing
%>
set conn=server.CreateObject("adodb.connection")
conn.open="driver={microsoft access driver (*.mdb)};dbq="&server.MapPath("db/#aaa.asp")
set ors=server.CreateObject("Adodb.RecordSet")
osql="select D_id,D_CataID,D_Title from [NewsData] where D_CataID='A0004' order by D_id desc"
ors.open osql,conn,1,1
response.write("<table width='98%' cellspacing=2 class=pt9>")
response.Write("<tr>")
i=1
do while not ors.eof
if i mod 3 = 1 then
response.write "</tr>"
end if
response.write "<td height='18'>·<a href='News/Show.asp?id="&ors("D_id")&"'>"&left(ors("D_Title"),3) &"</a></td>" '注意这里已被修改
if i mod 3 =0 then
response.write "</tr>"
end if
i = i + 1
ors.movenext
loop
response.write("</table>")
ors.close
set ors=nothing
%>
全部回答
- 1楼网友:持酒劝斜阳
- 2021-03-22 12:41
strflag = left((ors.Fields.Item("D_Title") .Value),4)
if(len(strflag)>=3) then
response.write(strflag)+"..."
else
response.write(strflag)
end if
response.write "<td height='18'>·<a href='News/Show.asp?id="&ors("D_id")&"'>"&strflag&"</a></td>"
当超过三个时后面加省略号少于三个则不变!
还有什么不明白的HI咨询!
- 2楼网友:行路难
- 2021-03-22 11:55
<%if len(trim(recordset5("focusing")))>10 then
a1 = left(trim(recordset1("字段")),10)&"..."
else
a1 = trim(recordset5("字段"))
end if
response.write a1
%>
- 3楼网友:末日狂欢
- 2021-03-22 10:53
if len(ors("D_id"))>3 then
response.write "<td height='18'>·<a href='News/Show.asp?id="&left(ors("D_id"),3)&"..."&"'>"&ors("D_Title") &"</a></td>"
else
response.write "<td height='18'>·<a href='News/Show.asp?id="&ors("D_id")&"'>"&ors("D_Title") &"</a></td>"
end if
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯