超难问题,牛人请进!解决立给分!
让用户在输入框中输入字母“C”,则从数据库中调出所有以“C”为首字母的汉字。
例如:输入字母“D”,则下拉列表框中显示出所有以声母“D”为开头的词,如:大智若愚。
这个如何实现,望高手指点。
问题点数:100、回复次数:24Top
1 楼preetyboy1982(爱情天地)回复于 2006-08-03 15:01:06 得分 5
不懂,帮顶一下Top
2 楼itzhiren(itzhiren)回复于 2006-08-03 15:15:58 得分 5
原理就是二级联动的原理,然后再加上汉字转拼音的程序就可以实现了Top
3 楼swazn_yj(菩提本无树)回复于 2006-08-03 15:22:04 得分 5
同意楼上的!Top
4 楼wdx1632(lg)回复于 2006-08-03 15:29:08 得分 0
汉字转拼音的程序,三楼的大哥能不能给些提示,这也是此问题的关键部分。Top
5 楼langrenkk(langrenkk)回复于 2006-08-03 15:31:59 得分 30
取汉字拼音首字母的存储过程:
Create function fun_getPY
(
@str nvarchar(4000)
)
returns nvarchar(4000)
as
begin
declare @word nchar(1),@PY nvarchar(4000)
set @PY=''
while len(@str)>0
begin
set @word=left(@str,1)
--如果非汉字字符,返回原字符
set @PY=@PY+(case when unicode(@word) between 19968 and 19968+20901
then (
select top 1 PY
from
(
select 'A' as PY,N'驁' as word
union all select 'B',N'簿'
union all select 'C',N'錯'
union all select 'D',N'鵽'
union all select 'E',N'樲'
union all select 'F',N'鰒'
union all select 'G',N'腂'
union all select 'H',N'夻'
union all select 'J',N'攈'
union all select 'K',N'穒'
union all select 'L',N'鱳'
union all select 'M',N'旀'
union all select 'N',N'桛'
union all select 'O',N'漚'
union all select 'P',N'曝'
union all select 'Q',N'囕'
union all select 'R',N'鶸'
union all select 'S',N'蜶'
union all select 'T',N'籜'
union all select 'W',N'鶩'
union all select 'X',N'鑂'
union all select 'Y',N'韻'
union all select 'Z',N'咗'
) T
where word>=@word collate Chinese_PRC_CS_AS_KS_WS
order by PY ASC
)
else @word
end)
set @str=right(@str,len(@str)-1)
end
return @PY
end
Top
6 楼teacher1998(英语+asp.net+MsSQL)回复于 2006-08-03 15:42:36 得分 5
顶Top
7 楼iamxiang(真心微笑)回复于 2006-08-03 15:55:40 得分 2
数据库:
名称 汉字缩写
大一 DY
小二 XE
再用程序读就出来了!
取首字拼音的程序很多!Top
8 楼wdx1632(lg)回复于 2006-08-03 16:04:43 得分 0
langrenkk,太感谢了。可是偶不太懂呀。
有没有简单点的????
因为,我不用SQLSERVER数据库呀。Top
9 楼LunTanZeng(筱淼)回复于 2006-08-03 16:05:31 得分 4
不是难事!
懂原理,就可实现Top
10 楼baihailong()回复于 2006-08-03 16:09:57 得分 4
上面的大哥哥,能不能简单介绍一下这段程序的原理!Top
11 楼wdx1632(lg)回复于 2006-08-03 16:17:04 得分 0
iamxiang,这位兄弟的想法自然是不错。可是这样做就太麻烦了。因为我们要事先建立相对应的关系,这要求大量的输入。所以,此方法不考虑。但还是感谢“iamxiang”Top
12 楼itzhiren(itzhiren)回复于 2006-08-03 16:48:43 得分 4
我这里有汉字转拼音的,就像iamxiang说的那样,不过不用数据库Top
13 楼ice241018(力挽狂澜)回复于 2006-08-03 16:57:02 得分 4
学习Top
14 楼FEB15(张郎)回复于 2006-08-03 17:56:01 得分 1
markTop
15 楼yutian130(骑着布什好歹的萨达姆猪,漫步在小巷的尽头)回复于 2006-08-04 14:16:01 得分 0
按声母排序就OK了。。
再加上ajax...Top
16 楼chinagkk1984(阿康)回复于 2006-08-04 16:15:27 得分 0
个人也认为用AJAX来实现起来,会比较快:)Top
17 楼jnzsk()回复于 2006-08-04 16:26:08 得分 1
你在输入汉字时把汉字的第一个字的拼音也输入进去!然后查询拼音的第一个字母!Top
18 楼nole2000(兰特)回复于 2006-08-04 16:44:19 得分 30
<%
function getpychar(char)
tmp=65536+asc(char)
if(tmp>=45217 and tmp<=45252) then
getpychar= "A"
elseif(tmp>=45253 and tmp<=45760) then
getpychar= "B"
elseif(tmp>=45761 and tmp<=46317) then
getpychar= "C"
elseif(tmp>=46318 and tmp<=46825) then
getpychar= "D"
elseif(tmp>=46826 and tmp<=47009) then
getpychar= "E"
elseif(tmp>=47010 and tmp<=47296) then
getpychar= "F"
elseif(tmp>=47297 and tmp<=47613) then
getpychar= "G"
elseif(tmp>=47614 and tmp<=48118) then
getpychar= "H"
elseif(tmp>=48119 and tmp<=49061) then
getpychar= "J"
elseif(tmp>=49062 and tmp<=49323) then
getpychar= "K"
elseif(tmp>=49324 and tmp<=49895) then
getpychar= "L"
elseif(tmp>=49896 and tmp<=50370) then
getpychar= "M"
elseif(tmp>=50371 and tmp<=50613) then
getpychar= "N"
elseif(tmp>=50614 and tmp<=50621) then
getpychar= "O"
elseif(tmp>=50622 and tmp<=50905) then
getpychar= "P"
elseif(tmp>=50906 and tmp<=51386) then
getpychar= "Q"
elseif(tmp>=51387 and tmp<=51445) then
getpychar= "R"
elseif(tmp>=51446 and tmp<=52217) then
getpychar= "S"
elseif(tmp>=52218 and tmp<=52697) then
getpychar= "T"
elseif(tmp>=52698 and tmp<=52979) then
getpychar= "W"
elseif(tmp>=52980 and tmp<=53688) then
getpychar= "X"
elseif(tmp>=53689 and tmp<=54480) then
getpychar= "Y"
elseif(tmp>=54481 and tmp<=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
response.write getpy("测")
%>
得到C
希望对你有帮助。Top
19 楼bclz_vs(边城)回复于 2006-08-04 16:49:03 得分 0
学习Top
20 楼zhangjincheng88(雪鹰)回复于 2006-08-04 16:53:07 得分 0
学习。。Top
21 楼xiaoyaowp(huanong)回复于 2006-08-04 20:32:58 得分 0
不错,顶Top
22 楼soft_2008(冬天到了,春天还远吗?)回复于 2006-08-04 22:13:29 得分 0
- -Top
23 楼smartcatiboy()回复于 2006-08-04 22:19:53 得分 0
>>>>nole2000(兰特)
>>>>nole2000(兰特)
>>>>nole2000(兰特)
大大,能否给一个中文字符和拼音对应的参考。Top
24 楼jiangsh100(著名菜鸟)回复于 2006-08-04 23:58:22 得分 0
多一个字段匹配中文字段的名称的声母
Top




