C#(asp.net)仿baidu或google智能匹配搜索下拉框
来源:互联网 发布:看台风的软件 编辑:程序博客网 时间:2024/05/22 02:10
页面文件代码:
<div class="inputdiv" style="top:215px;">
<div class="search">
<input name="keyword" type="text" class="input2" id="keyword" value="" style="float:left;" onkeyup="keySelectHistory2()" onclick="keySelectHistory()"/>//文本输入框
<input name="drpservicearea" id="drpservicearea" type="hidden" />//选择后的数字值
<span class="submit" onClick="return keySelectHistory();"></span></div>//下拉框的点击
</div>
<div class="text" style="SCROLLBAR-FACE-COLOR: #C2C2C2; SCROLLBAR-HIGHLIGHT-COLOR: #D8D7D5; OVERFLOW: auto; SCROLLBAR-SHADOW-COLOR: #808080; SCROLLBAR-ARROW-COLOR: #000000; SCROLLBAR-DARKSHADOW-COLOR: #000000; BACKGROUND-COLOR: #FFFFFF" id="keytext" style="display:none">
</div>//下拉框效果
css代码:
.search{float: left;height: 22px;width: 165px;margin: 0px;padding: 0px;}
.search .input2{padding-top:2px;height:22px;width: 155px;font-size:12px;background:#fff url(../../images/ClientLogin1/search_btn.gif) no-repeat right 0;
}
.btn{ padding:0px; margin:0px; float:left;}
.label{color:#ccc;position:absolute;left:12px;top:0px;display:block;height:22px;line-height:22px;font-size:12px;}
span.submit{cursor:pointer;position:absolute;left:138px;top:0px;width:20px;height:20px;text-indent:-999em;}
.text{width:154px; HEIGHT: 200px;margin:5px 0px;padding: 0px; position:absolute; top:230px; left:176px; z-index:2; background-color:#fff; overflow:hidden; border:1px solid #404040;}
.text ul {margin: 0px;padding: 0px;text-align: left;clear: left;height: auto;width: 153px;}
.text li{height: auto;width: 153px;margin: 0px;padding: 0px;background-color:#fff;position:relative;text-indent: 5px;}
.text p{line-height: 20px;font-size: 10px;font-family: Verdana, Arial, Helvetica, sans-serif;margin: 0px;padding: 0px;text-align: justify;font-weight: normal;color: #000000;text-indent: 10px;height: 20px;}
css中用到的图片文件:
js代码:
function keySelectHistory()
{
document.getElementById('keytext').style.display = ''
}
function keySelectHistory2()
{
var key=document.getElementById('keyword').value;
var sendData="key="+key+"";
var result=postHTML("service/Chooserealm.aspx", sendData, function(result){receive_CallBack(result) });
}
function receive_CallBack(result)
{
if(result==false) { return; }
document.getElementById('keytext').className="text";
document.getElementById('keytext').innerHTML =result;
}
Chooserealm.aspx文件代码:
string key = Microsoft.JScript.GlobalObject.unescape(Request["key"]).Trim();
string Remark = "1=1";
if (key == null || key == "")
{
Remark = "1=1";
}
else
{
Remark = " service_text like '" + key + "%'";
}
DataTable dt = new chat.dal.chatconnect().chat_service_getlistremark(1, Remark);
string result = "";
for (int i = 0; i < dt.Rows.Count; i++)
{
result += "<p onMouseOver=\"this.style.backgroundColor='#B4D7E9';\" onMouseOut=\"this.style.backgroundColor=''\" onClick=\"clickkey('" + dt.Rows[i]["service_text"].ToString().Trim() + "'," + dt.Rows[i]["id"].ToString().Trim() + ")\" style=\"cursor:pointer\">" + dt.Rows[i]["service_text"].ToString().Trim() + "</p>";
}
Response.Clear();
Response.Write(result);
Response.End();
存储过程代码:
CREATE PROCEDURE [dbo].[chat_service_getlistremark]
@pid int,
@Remark varchar(100)
AS
--如果不存在下一级服务列表,则返回父节点服务记录
declare @sql nvarchar(2000)
IF NOT EXISTS( SELECT [id] from chatservice where pid=@pid)
set @sql='select [id],[pid],[service_text],[service],isendnode from chatservice where [id]='+cast(@pid as varchar(20))+' and useflag=1 and '+@Remark+''
ELSE
set @sql='select [id],[pid],[service_text],[service],isendnode from chatservice where pid='+cast(@pid as varchar(20))+' and useflag=1 and '+@Remark+' order by vieworder asc'
exec sp_Executesql @sql
<div class="inputdiv" style="top:215px;">
<div class="search">
<input name="keyword" type="text" class="input2" id="keyword" value="" style="float:left;" onkeyup="keySelectHistory2()" onclick="keySelectHistory()"/>//文本输入框
<input name="drpservicearea" id="drpservicearea" type="hidden" />//选择后的数字值
<span class="submit" onClick="return keySelectHistory();"></span></div>//下拉框的点击
</div>
<div class="text" style="SCROLLBAR-FACE-COLOR: #C2C2C2; SCROLLBAR-HIGHLIGHT-COLOR: #D8D7D5; OVERFLOW: auto; SCROLLBAR-SHADOW-COLOR: #808080; SCROLLBAR-ARROW-COLOR: #000000; SCROLLBAR-DARKSHADOW-COLOR: #000000; BACKGROUND-COLOR: #FFFFFF" id="keytext" style="display:none">
</div>//下拉框效果
css代码:
.search{float: left;height: 22px;width: 165px;margin: 0px;padding: 0px;}
.search .input2{padding-top:2px;height:22px;width: 155px;font-size:12px;background:#fff url(../../images/ClientLogin1/search_btn.gif) no-repeat right 0;
}
.btn{ padding:0px; margin:0px; float:left;}
.label{color:#ccc;position:absolute;left:12px;top:0px;display:block;height:22px;line-height:22px;font-size:12px;}
span.submit{cursor:pointer;position:absolute;left:138px;top:0px;width:20px;height:20px;text-indent:-999em;}
.text{width:154px; HEIGHT: 200px;margin:5px 0px;padding: 0px; position:absolute; top:230px; left:176px; z-index:2; background-color:#fff; overflow:hidden; border:1px solid #404040;}
.text ul {margin: 0px;padding: 0px;text-align: left;clear: left;height: auto;width: 153px;}
.text li{height: auto;width: 153px;margin: 0px;padding: 0px;background-color:#fff;position:relative;text-indent: 5px;}
.text p{line-height: 20px;font-size: 10px;font-family: Verdana, Arial, Helvetica, sans-serif;margin: 0px;padding: 0px;text-align: justify;font-weight: normal;color: #000000;text-indent: 10px;height: 20px;}
css中用到的图片文件:
js代码:
function keySelectHistory()
{
document.getElementById('keytext').style.display = ''
}
function keySelectHistory2()
{
var key=document.getElementById('keyword').value;
var sendData="key="+key+"";
var result=postHTML("service/Chooserealm.aspx", sendData, function(result){receive_CallBack(result) });
}
function receive_CallBack(result)
{
if(result==false) { return; }
document.getElementById('keytext').className="text";
document.getElementById('keytext').innerHTML =result;
}
Chooserealm.aspx文件代码:
string key = Microsoft.JScript.GlobalObject.unescape(Request["key"]).Trim();
string Remark = "1=1";
if (key == null || key == "")
{
Remark = "1=1";
}
else
{
Remark = " service_text like '" + key + "%'";
}
DataTable dt = new chat.dal.chatconnect().chat_service_getlistremark(1, Remark);
string result = "";
for (int i = 0; i < dt.Rows.Count; i++)
{
result += "<p onMouseOver=\"this.style.backgroundColor='#B4D7E9';\" onMouseOut=\"this.style.backgroundColor=''\" onClick=\"clickkey('" + dt.Rows[i]["service_text"].ToString().Trim() + "'," + dt.Rows[i]["id"].ToString().Trim() + ")\" style=\"cursor:pointer\">" + dt.Rows[i]["service_text"].ToString().Trim() + "</p>";
}
Response.Clear();
Response.Write(result);
Response.End();
存储过程代码:
CREATE PROCEDURE [dbo].[chat_service_getlistremark]
@pid int,
@Remark varchar(100)
AS
--如果不存在下一级服务列表,则返回父节点服务记录
declare @sql nvarchar(2000)
IF NOT EXISTS( SELECT [id] from chatservice where pid=@pid)
set @sql='select [id],[pid],[service_text],[service],isendnode from chatservice where [id]='+cast(@pid as varchar(20))+' and useflag=1 and '+@Remark+''
ELSE
set @sql='select [id],[pid],[service_text],[service],isendnode from chatservice where pid='+cast(@pid as varchar(20))+' and useflag=1 and '+@Remark+' order by vieworder asc'
exec sp_Executesql @sql
0 0
- C#(asp.net)仿baidu或google智能匹配搜索下拉框
- C#(asp.net)仿baidu或google智能匹配搜索下拉框
- 仿Google的搜索下拉框
- asp.net 仿百度搜索 智能感知快速搜索
- 仿google智能下拉ajax非插件
- C# Asp.Net自动调用百度搜索页面baidu/google搜索页面
- 仿Google搜索框
- 浅谈asp.net通过本机cookie仿百度(google)实现搜索input框自动弹出搜索提示
- 仿 google baidu 自动提示框
- jquery+MVC 实现類似baidu,google搜索 提示下拉框
- baidu google 下拉框 的简单实现
- 仿google、百度搜索框输入信息智能提示的实现 兼容主流浏览器
- 仿google、百度搜索框输入信息智能提示的实现 兼容主流浏览器
- asp.net可搜索下拉框,支持中文
- 仿百度智能提示搜索框
- google 搜索提示 搜索下拉框 jquery
- 仿google suggest 下拉列表框
- 仿google的下拉提示框
- Makefile 里的 subst 函数
- //2、在主函数中输入10个等长的字符串。用另一个函数对它们排序,然后主函数输出10个已经排好的字符串。
- 制作自己的电子地图
- Android Application 对象介绍
- hdoj 1093 A+B for Input-Output Practice (V)
- C#(asp.net)仿baidu或google智能匹配搜索下拉框
- ArcGlobe 缓存管理
- hdoj 1094 A+B for Input-Output Practice (VI)
- hdoj 1095 A+B for Input-Output Practice (VII)
- hdoj 1096 A+B for Input-Output Practice (VIII)
- Nodejs开发框架Express4.2.0简单开始
- java 通过反射获得泛型的实际类型参数
- hdoj 1032 又一版 A+B
- NSNotification、delegate和KVO的区别