主题:  请教!如何把搜索的关键字改为红色

南山网站开发

职务:普通成员
等级:1
金币:0.0
发贴:12
注册:2005/11/12 13:15:57
#12005/11/15 15:50:24
各位大虾,我已经把搜索系统做好了,但我想把搜索的关键字改为红色,只知道是用替换法作的,但不知道该怎么写这段代码,会用的朋友能帮忙写一下吗?非常感谢!!!
以下是我搜索页的源代码,希望会写的朋友帮我写一下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn/conn.asp"-->
<%
dim m,n
a=request.Form("tt"
set rs=server.CreateObject("ADODB.recordset"
sql="SELECT * FROM fenlen where xl LIKE '%"&a&"%' Order by uid desc"
rs.open sql,connstr,3,3
cc=rs.recordcount
if(cc=0) then
response.Write ("对不起!暂时还没有该类产品!<p><a href='001.asp'>点击这里返回</a>"
response.end()
else
end if
<% if(len(rs("cptxt")>100) then
else
end if
%>
<html>
<head>
<style type="text/css">
<!--
#f{
border-collapse: collapse;
}
-->

</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>中国采购信息网</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#004E98" leftmargin="0" topmargin="0">
<div align="center">
<table width="625" height="305" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td><div align="center">
<%
n=1
while not rs.eof and n<=rs.pagesize %>
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="img/006.jpg" width="10" height="5"></td>
</tr>
</table>
<table width="570" height="22" border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC" id="f">
<tr>
<td width="72" height="20" align="right" valign="middle" class="txt"><div align="center"><strong>产品名称:</strong></div></td>
<td width="394" class="txt">  <%=(rs("cpname")%>      
<div align="center"></div>
<div align="center"></div></td>
<td width="96" class="txt"><div align="center"><a href="fenle1.asp?id=<%=(rs("id")%>" target="_blank">查看详细信息</a></div></td>
</tr>
</table>
<% n=n+1
rs.movenext
wend
%>
<br>
</div></td>
</tr>
</table>
</div>
</body>
</html>



缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
注册:2004/1/14 19:14:47
#22005/11/15 16:26:52
Replace(f,k,"<font color=red>"&k&"</font>"



南山网站开发

职务:普通成员
等级:1
金币:0.0
发贴:12
注册:2005/11/12 13:15:57
#32005/11/15 17:31:28
二楼!非常感谢你!请问这段代码加在那个地方



南山网站开发

职务:普通成员
等级:1
金币:0.0
发贴:12
注册:2005/11/12 13:15:57
#42005/11/15 17:32:41
其中的f,k,是什么意思??



缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
注册:2004/1/14 19:14:47
#52005/11/15 19:55:47
这个是告诉你方法,又不是什么特效,复制粘贴就能看到效果

你看一下VBS中Replace函数的方法



南山网站开发

职务:普通成员
等级:1
金币:0.0
发贴:12
注册:2005/11/12 13:15:57
#62005/11/16 9:08:18
谢谢!



南山网站开发

职务:普通成员
等级:1
金币:0.0
发贴:12
注册:2005/11/12 13:15:57
#72005/11/16 13:44:23
我搞了好久没搞成功.还是请你帮我加到我源代码当中好吗?我比较急!!



sdawenye

职务:普通成员
等级:1
金币:0.0
发贴:16
注册:2005/12/19 18:57:21
#82006/1/5 10:49:00
这个对初学者不好搞啊呀