基于jquery的文本框与autocomplete结合使用(asp.net+json)_jquery
程序员文章站
2022-05-12 15:08:45
...
JS脚本引用
样式引用
JS代码
?$(document).ready(function () {
$("#").autocomplete("./AjaxHandle/AutoComplete.ashx?type=game", {
minChars: 0,
max: 9,
width: 150,
matchContains: true,
autoFill: false,
formatItem: function (row, i, max) {
return row.name;
},
formatMatch: function (row, i, max) {
return row.name + " ";
},
formatResult: function (row) {
return row.name;
}
});
jQuery("#").result(function (event, data, formatted) {
if (data) {
jQuery("#_SearchKeyGame").attr("value", data.name);
}
else {
}
});
$("#").autocomplete("./AjaxHandle/AutoComplete.ashx?type=plat", {
minChars: 0,
max: 9,
width: 150,
matchContains: true,
autoFill: false,
formatItem: function (row, i, max) {
return row.name;
},
formatMatch: function (row, i, max) {
return row.name + " ";
},
formatResult: function (row) {
return row.name;
}
});
AutoComplete。ashx返回JOSON值
string queryStr = context.Request.QueryString["q"];
context.Response.ContentType = "text/plain";
context.Response.Cache.SetNoStore();
string jsponString = "[";
string where = string.Format(" (select dbo.[f_GetPy](platname)) like '%{0}%' or platname like '%{0}%'", Common.Common.ToSql(queryStr));
DataTable dt = new Models.Plat().GetDataTable(where,10);
if (dt.Rows.Count > 0)
{
for (int i = 0; i {
jsponString += "{id:\"" + dt.Rows[i]["PlatID"].ToString() + "\",name:\"" + dt.Rows[i]["PlatName"].ToString() + "\"},";
}
}
jsponString = jsponString.Trim(new char[] { ',' });
jsponString += "]";
context.Response.Write(jsponString);
context.Response.End();
复制代码 代码如下:
样式引用
复制代码 代码如下:
JS代码
复制代码 代码如下:
?$(document).ready(function () {
$("#").autocomplete("./AjaxHandle/AutoComplete.ashx?type=game", {
minChars: 0,
max: 9,
width: 150,
matchContains: true,
autoFill: false,
formatItem: function (row, i, max) {
return row.name;
},
formatMatch: function (row, i, max) {
return row.name + " ";
},
formatResult: function (row) {
return row.name;
}
});
jQuery("#").result(function (event, data, formatted) {
if (data) {
jQuery("#_SearchKeyGame").attr("value", data.name);
}
else {
}
});
$("#").autocomplete("./AjaxHandle/AutoComplete.ashx?type=plat", {
minChars: 0,
max: 9,
width: 150,
matchContains: true,
autoFill: false,
formatItem: function (row, i, max) {
return row.name;
},
formatMatch: function (row, i, max) {
return row.name + " ";
},
formatResult: function (row) {
return row.name;
}
});
AutoComplete。ashx返回JOSON值
复制代码 代码如下:
string queryStr = context.Request.QueryString["q"];
context.Response.ContentType = "text/plain";
context.Response.Cache.SetNoStore();
string jsponString = "[";
string where = string.Format(" (select dbo.[f_GetPy](platname)) like '%{0}%' or platname like '%{0}%'", Common.Common.ToSql(queryStr));
DataTable dt = new Models.Plat().GetDataTable(where,10);
if (dt.Rows.Count > 0)
{
for (int i = 0; i {
jsponString += "{id:\"" + dt.Rows[i]["PlatID"].ToString() + "\",name:\"" + dt.Rows[i]["PlatName"].ToString() + "\"},";
}
}
jsponString = jsponString.Trim(new char[] { ',' });
jsponString += "]";
context.Response.Write(jsponString);
context.Response.End();
上一篇: 织梦CMS中图片处理类
下一篇: HTML怎么实现数字焦点图轮播代码
推荐阅读
-
基于jquery的文本框与autocomplete结合使用(asp.net+json)
-
基于jquery的文本框与autocomplete结合使用(asp.net+json)_jquery
-
基于jquery的文本框与autocomplete结合使用(asp.net+json)
-
基于jquery的文本框与autocomplete结合使用(asp.net+json)_jquery
-
基于Bootstrap使用jQuery实现输入框组input-group的添加与删除_javascript技巧
-
基于Bootstrap使用jQuery实现输入框组input-group的添加与删除_javascript技巧