关于迅雷搜索框出现的那种拼音搜索出相关的汉字

零起飞 2008-04-21 10:41:17
有个表保存了地名(汉字)等信息,现在我想在combox输入框中输入地名的第一个字母(或第一和第二个字母)的时候能把首字母含有此字母的地名列出来。
例如:输入 "S "能把“山东”、“山西”、“汕头”等列出来。
输入"wm" 能把"我们" "外面" "文明" "完美"等列出来

看了网上一些例子,但总不够理想,希望各位能给个例子
...全文
163 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
零起飞 2008-04-21
  • 打赏
  • 举报
回复
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../inc/conn.asp"-->
<%
'-----------------------------------------------------------------
dim keyword
keyword=trim(request.Form("keyword")) '接收ajax发送的参数
if keyword="" then response.End()
'------------------------------------------------------------------
function getpychar(char)
dim tmpp:tmpp=65536+asc(char)
if(tmpp>=45217 and tmpp<=45252) then
getpychar= "A"
elseif(tmpp>=45253 and tmpp<=45760) then
getpychar= "B"
elseif(tmpp>=45761 and tmpp<=46317) then
getpychar= "C"
elseif(tmpp>=46318 and tmpp<=46825) then
getpychar= "D"
elseif(tmpp>=46826 and tmpp<=47009) then
getpychar= "E"
elseif(tmpp>=47010 and tmpp<=47296) then
getpychar= "F"
elseif(tmpp>=47297 and tmpp<=47613) then
getpychar= "G"
elseif(tmpp>=47614 and tmpp<=48118) then
getpychar= "H"
elseif(tmpp>=48119 and tmpp<=49061) then
getpychar= "J"
elseif(tmpp>=49062 and tmpp<=49323) then
getpychar= "K"
elseif(tmpp>=49324 and tmpp<=49895) then
getpychar= "L"
elseif(tmpp>=49896 and tmpp<=50370) then
getpychar= "M"
elseif(tmpp>=50371 and tmpp<=50613) then
getpychar= "N"
elseif(tmpp>=50614 and tmpp<=50621) then
getpychar= "O"
elseif(tmpp>=50622 and tmpp<=50905) then
getpychar= "P"
elseif(tmpp>=50906 and tmpp<=51386) then
getpychar= "Q"
elseif(tmpp>=51387 and tmpp<=51445) then
getpychar= "R"
elseif(tmpp>=51446 and tmpp<=52217) then
getpychar= "S"
elseif(tmpp>=52218 and tmpp<=52697) then
getpychar= "T"
elseif(tmpp>=52698 and tmpp<=52979) then
getpychar= "W"
elseif(tmpp>=52980 and tmpp<=53640) then
getpychar= "X"
elseif(tmpp>=53689 and tmpp<=54480) then
getpychar= "Y"
elseif(tmpp>=54481 and tmpp<=62289) then
getpychar= "Z"
else '如果不是中文,则不处理
getpychar=char
end if
end function
'//生成汉字串首字母串
function getpy(str)
for i=1 to len(str)
getpy=getpy & getpychar(mid(str,i,1))
next
end function
'------------------------------------------------------------------
set rs=server.CreateObject("adodb.recordset")
sql="select * from sightSpot where sight_spot_name like '%"&keyword&"%' order by sight_spot_ID desc"
rs.open sql,conn,1,1
'------------------------------------------------------------------
现在我是想把sight_spot_name里的字段汉字首字母提出来与 keyword 相配如果有就显示
'***********************************************************
'--------如果没有找到的话,返回0
'--------如果找到的话,返回所有匹配的项目
if not (rs.eof and rs.bof) then
response.Write("<ul>")
for i=0 to 9
if rs.eof then exit for
response.Write("<li value="""&i&""" onclick=""form_submit()"" onmouseover=""mo(this.value)"">"&rs("sight_spot_name")&"<span>约"&rs.pagecount &"结果</span></li>")
rs.movenext
next
response.Write("</ul>")
Else
response.Write("<ul>")
response.Write("<li>""<font color=""#ff0000"">   对不起!没有你所搜索出的结果请联系管理员添加此旅行社</font>""</li>")
response.Write("</ul>")
End If
rs.close
set rs=nothing
%>
No_Data_Found 2008-04-21
  • 打赏
  • 举报
回复
那个这个到度怎么实现
-------------------------------

google suggest

yui autoComplete
零起飞 2008-04-21
  • 打赏
  • 举报
回复
那个这个到度怎么实现,能不能给出个例子来呀.,
littlelam 2008-04-21
  • 打赏
  • 举报
回复
下个拼音输入法的字库就行了,我有js版的拼音和五笔输入法字库
文盲老顾 2008-04-21
  • 打赏
  • 举报
回复
做词条记忆吧,然后根据使用频率排序列出
No_Data_Found 2008-04-21
  • 打赏
  • 举报
回复
程序好实现 关键是那个数据 比较难维护

28,409

社区成员

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

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