<html>
<head>
</head>
<body>
<form id="recordform" name="recordform" autocomplete="off">
<table cellpadding="0" cellspacing="0" class="tablepadding">
<%-- <tr>
<td rowspan="7" style="width: 40%;">
<select size="4" name="lboxReceive" id="lboxReceive" tabindex="-1" style="width: 100%; height: 90%;">
</select>
</td>
</tr>--%>
<tr>
<th>收货人:</th>
<td>
<input id="txtReceiveName" name="txtReceiveName" type="text" class="form-control required" paihang /><span class="required"></span></td>
</tr>
<tr>
<th>手 机:</th>
<td>
<input id="txtReceiveHand" name="txtReceiveHand" type="text" class="form-control" paihang /></td>
</tr>
<tr>
<th>电 话:</th>
<td>
<input id="txtReceiveTel" name="txtReceiveTel" type="text" class="form-control" paihang /></td>
</tr>
<tr>
<th>单 位:</th>
<td>
<input id="txtReceiveCorp" name="txtReceiveCorp" maxlength="200" type="text" class="form-control" paihang /></td>
</tr>
<tr>
<th>地 址:</th>
<td>
<input id="txtReceiveAddress" name="txtReceiveAddress" maxlength="200" type="text" class="form-control" paihang /></td>
</tr>
<tr>
<th> </th>
<td> </td>
</tr>
</table>
</form>
<script type="text/javascript">
$(function () {
inputBindQuery("txtSendName", txtNamechange);
});
function txtNamechange() {
MessageError = MessageError + 1;
$("#txtSendName_Id").val("");//清空发货方id
var stationName = $("#dropAcceptStation").find("option:selected").text().trim();
if (stationName !== "请选择") {
var queryParams = {
"columns": "<%=QueryTypeKey.发货方_发货方%>,<%=QueryTypeKey.发货方_联系人%>,<%=QueryTypeKey.发货方_手机%>,<%=QueryTypeKey.发货方_电话%>,<%=QueryTypeKey.发货方_单位%>,<%=QueryTypeKey.发货方_地址%>",
"sorts": "<%=QueryTypeKey.发货方_发货方%>",
"queryType": "<%=(int)QueryType.CustomerShipperInfo%>",
"searchKey": $("#txtSendName").val(),
"stationName": stationName
};
var options = { "queryParams": queryParams };
options.setData = setData;
autocomplete("txtSendName", options);
} else {
if (MessageError===1) {
alert("请先选择揽收站点!");
}
}
};
//选择下拉框内容后回调填充方法
function setData(dt) {
$("#txtSendName").val(dt[0]);
$("#txtSendLinkUser").val(dt[1]);
$("#txtSendHand").val(dt[2]);
$("#txtSendTel").val(dt[3]);
$("#txtSendCorp").val(dt[4]);
$("#txtSendAddress").val(dt[5]);
$("#txtSendName_Id").val(dt[6]);
//设置收货方为输入项
$("#txtReceiveName").focus();
$("#txtReceiveName").val(dt[0]);
txtNamechange4();
$("#txtReceiveName").val("");
};
</script>
</body>
</html>
智能提示html 代码
var new_element = document.createElement("script");
new_element.setAttribute("type", "text/javascript");
new_element.setAttribute("src", "/content/bjui/plugins/bootstrap.min.js");
document.body.appendChild(new_element);
/**
* jQuery "splendid textchange" plugin
* http://benalpert.com/2013/06/18/a-near-perfect-oninput-shim-for-ie-8-and-9.html
*为了适应ie 8 9 不触发弹框
* (c) 2013 Ben Alpert, released under the MIT license
*/ (function ($) { var testNode = document.createElement("input");
var isInputSupported = "oninput" in testNode &&
(!("documentMode" in document) || document.documentMode > 9); var hasInputCapabilities = function (elem) {
// The HTML5 spec lists many more types than `text` and `password` on
// which the input event is triggered but none of them exist in IE 8 or
// 9, so we don't check them here.
// TODO: <textarea> should be supported too but IE seems to reset the
// selection when changing textarea contents during a selectionchange
// event so it's not listed here for now.
return elem.nodeName === "INPUT" &&
(elem.type === "text" || elem.type === "password");
}; var activeElement = null;
var activeElementValue = null;
var activeElementValueProp = null; /**
* (For old IE.) Replacement getter/setter for the `value` property that
* gets set on the active element.
*/
var newValueProp = {
get: function () {
return activeElementValueProp.get.call(this);
},
set: function (val) {
activeElementValue = val;
activeElementValueProp.set.call(this, val);
}
}; /**
* (For old IE.) Starts tracking propertychange events on the passed-in element
* and override the value property so that we can distinguish user events from
* value changes in JS.
*/
var startWatching = function (target) {
activeElement = target;
activeElementValue = target.value;
activeElementValueProp = Object.getOwnPropertyDescriptor(
target.constructor.prototype, "value"); Object.defineProperty(activeElement, "value", newValueProp);
activeElement.attachEvent("onpropertychange", handlePropertyChange);
}; /**
* (For old IE.) Removes the event listeners from the currently-tracked
* element, if any exists.
*/
var stopWatching = function () {
if (!activeElement) return; // delete restores the original property definition
delete activeElement.value;
activeElement.detachEvent("onpropertychange", handlePropertyChange); activeElement = null;
activeElementValue = null;
activeElementValueProp = null;
}; /**
* (For old IE.) Handles a propertychange event, sending a textChange event if
* the value of the active element has changed.
*/
var handlePropertyChange = function (nativeEvent) {
if (nativeEvent.propertyName !== "value") return; var value = nativeEvent.srcElement.value;
if (value === activeElementValue) return;
activeElementValue = value; $(activeElement).trigger("textchange");
}; if (isInputSupported) {
$(document)
.on("input", function (e) {
// In modern browsers (i.e., not IE 8 or 9), the input event is
// exactly what we want so fall through here and trigger the
// event...
if (e.target.nodeName !== "TEXTAREA") {
// ...unless it's a textarea, in which case we don't fire an
// event (so that we have consistency with our old-IE shim).
$(e.target).trigger("textchange");
}
});
} else {
$(document)
.on("focusin", function (e) {
// In IE 8, we can capture almost all .value changes by adding a
// propertychange handler and looking for events with propertyName
// equal to 'value'.
// In IE 9, propertychange fires for most input events but is buggy
// and doesn't fire when text is deleted, but conveniently,
// selectionchange appears to fire in all of the remaining cases so
// we catch those and forward the event if the value has changed.
// In either case, we don't want to call the event handler if the
// value is changed from JS so we redefine a setter for `.value`
// that updates our activeElementValue variable, allowing us to
// ignore those changes.
if (hasInputCapabilities(e.target)) {
// stopWatching() should be a noop here but we call it just in
// case we missed a blur event somehow.
stopWatching();
startWatching(e.target);
}
}) .on("focusout", function () {
stopWatching();
}) .on("selectionchange keyup keydown", function () {
// On the selectionchange event, e.target is just document which
// isn't helpful for us so just check activeElement instead.
//
// 90% of the time, keydown and keyup aren't necessary. IE 8 fails
// to fire propertychange on the first input event after setting
// `value` from a script and fires only keydown, keypress, keyup.
// Catching keyup usually gets it and catching keydown lets us fire
// an event for the first keystroke if user does a key repeat
// (it'll be a little delayed: right before the second keystroke).
// Other input methods (e.g., paste) seem to fire selectionchange
// normally.
if (activeElement && activeElement.value !== activeElementValue) {
activeElementValue = activeElement.value;
$(activeElement).trigger("textchange");
}
});
} })(jQuery); (function ($) {
//document.write('<script type="text/javascript" src="/content/common/js/modules/jquerySplendidTextchange.js">');
document.write('<style>' +
' .bigautocomplete-layout{display:none;background-color:#FFFFFF;border:1px solid #BCBCBC;position:absolute;z-index:100;max-height:220px;overflow-x:hidden;overflow-y:auto; }' +
'.bigautocomplete-layout table{border-collapse:collapse;border-spacing:0;background:none repeat scroll 0 0 #FFFFFF;width:100%;cursor:default;}' +
'.bigautocomplete-layout table tr:nth-child(odd){background:none repeat scroll 0 0 #fbf6f6;}' +
'.bigautocomplete-layout table tr:nth-child(even){background:none repeat scroll 0 0 #FFFFFF;}' +
'.bigautocomplete-layout table tr td{border-top: 1px solid #EAEAEA;border-left: 1px solid #EAEAEA;text-align:center;padding:0 5px;}' +
'.bigautocomplete-layout table tr td:nth-child(1){border-left: 0px;}' +
'.bigautocomplete-layout .ct{background:none repeat scroll 0 0 #D2DEE8 !important;}' +
'.bigautocomplete-layout div{word-wrap:break-word;word-break:break-all;padding:1px 5px;}' +
'</style>'); var bigAutocomplete = new function () { this.currentInputText = null; //目前获得光标的输入框(解决一个页面多个输入框绑定自动补全功能)
this.functionalKeyArray = [
9, 20, 13, 16, 17, 18, 91, 92, 93, 45, 36, 33, 34, 35, 37, 39, 112, 113, 114, 115, 116, 117, 118, 119, 120,
121, 122, 123, 144, 19, 145, 40, 38, 27
]; //键盘上功能键键值数组
this.holdText = null; //输入框中原始输入的内容
var queryData = []; //数据集合
//初始化插入自动补全div,并在document注册mousedown,点击非div区域隐藏div
this.init = function() {
queryData = [];
$("body").append("<div id='bigAutocompleteContent' class='bigautocomplete-layout'></div>");
//$("#" + _input_id).blur(function () {
// bigAutocomplete.hideAutocomplete();
//}); $(document).bind('mousedown',
function(event) {
var $target = $(event.target);
if ((!($target.parents().andSelf().is('#bigAutocompleteContent'))) &&
(!$target.is(bigAutocomplete.currentInputText))) {
bigAutocomplete.hideAutocomplete();
}
}); //鼠标悬停时选中当前行
$("#bigAutocompleteContent").delegate("tr",
"mouseover",
function () {
mate = "1";
$("#bigAutocompleteContent tr").removeClass("ct");
$(this).addClass("ct");
}).delegate("tr",
"mouseout",
function() {
$("#bigAutocompleteContent tr").removeClass("ct");
}); //单击选中行后,选中行内容设置到输入框中,并执行callback函数
$("#bigAutocompleteContent").delegate("tr",
"click",
function (tr) {
mate = "1";
hintfun();
//bigAutocomplete.currentInputText.val($(this).find("div:last").html());
//onDataSelected($(this).find("div:last").html());
var data = [];
var tdthis = $("td", $(this)[0]);
for (var i = 0; i < $(tdthis).length; i++) {
data.push($(tdthis[i]).text());
}
onDataSelected(data);
//var callback_ = bigAutocomplete.currentInputText.data("config").callback;
var callback_ = bigAutocomplete.currentInputText;
if ($("#bigAutocompleteContent").css("display") != "none" && callback_ && $.isFunction(callback_)) { callback_(data); }
chuangetext = ""; bigAutocomplete.hideAutocomplete();
}); } //提示方法
function hintfun() {
//if (mate == "0"&&_required==true) {
// bigAutocomplete.hideAutocomplete();
// if (mate == "0") {
// //$("#" + _input_id).val("");
// //$("#" + _input_id).parent().find("span").html("请从智能提示中选择!");
// //$("#" + _input_id).parent().find("span").html("<span class='hintSpan'></span>");
// if ($("#" + _input_id).parent().find("span").hasClass("beHint")==false)
// {
// $("#" + _input_id).parent().append("<span class='hintSpan'></span>");
// }
// $("#" + _input_id).parent().find("span").addClass("red beHint");
// $("#" + _input_id).parent().find(".hintSpan").tooltip({
// trigger: 'hover',
// html: true,
// title: '请从下拉选择'
// }); // } else {
// $("#" + _input_id).parent().find("span").removeClass("beHint");
// $("#" + _input_id).parent().find(".hintSpan").css("display","none"); // }
//} else if (mate == "1"&&_required==true) {
// $("#" + _input_id).parent().find("span").html("");
//} //bigAutocomplete.hideAutocomplete();
if (_required == true) {
//$("#" + _input_id).val("");
//$("#" + _input_id).parent().find("span").html("请从智能提示中选择!");
//$("#" + _input_id).parent().find("span").html("<span class='hintSpan'></span>");
if ($("#" + _input_id).parent().find("span").hasClass("beHint") == false) {
$("#" + _input_id).parent().append("<span class='hintSpan'></span>");
}
$("#" + _input_id).parent().find("span").addClass("red beHint");
$("#" + _input_id).parent().find(".hintSpan").popover({
trigger:'click',
placement:'top',
content: '请从下拉选择!'
});
$(function () { $("#" + _input_id).parent().find(".hintSpan").popover('show'); }); } else {
$("#" + _input_id).parent().find("span").removeClass("beHint");
$("#" + _input_id).parent().find(".hintSpan").css("display", "none");
$(function () { $("#" + _input_id).parent().find(".hintSpan").popover('hide'); });
}
//判断下拉列表是否匹配
judge();
if (mate == "1" && _required == true) {
$("#" + _input_id).parent().find("span").removeClass("beHint");
$("#" + _input_id).parent().find(".hintSpan").css("display", "none");
$(function () { $("#" + _input_id).parent().find(".hintSpan").popover('hide'); });
} } this.autocomplete = function (param) { //输入框失去焦点事件
$("#" + _input_id).unbind('blur');
if (_required == true) {
$("#" + _input_id).bind('blur', function () {
hintfun();
});
} if ($("body").length > 0 && $("#bigAutocompleteContent").length <= 0) {
bigAutocomplete.init(); //初始化信息
} var $this = $(this); //为绑定自动补全功能的输入框jquery对象 var $bigAutocompleteContent = $("#bigAutocompleteContent"); this.config = {
//width:下拉框的宽度,默认使用输入框宽度
width: $this.outerWidth() - 2,
//url:格式url:""用来ajax后台获取数据,返回的数据格式为data参数一样
url: null,
/*data:格式{data:[{title:null,result:{}},{title:null,result:{}}]}
url和data参数只有一个生效,data优先*/
data: null,
//callback:选中行后按回车或单击时回调的函数
callback: null
};
$.extend(this.config, param);
$this.data("config", this.config); $this.unbind("keydown");
$this.unbind("keyup"); //改变事件事件
var searchTxt = $(this).val();
if (searchTxt == "") {
chuangetext = "";
}
if (searchTxt != chuangetext) {
var params = null;
params = $.extend({}, _options.queryParams, { "SearchTxt": searchTxt });
//console.log(params)
//var params = { "SearchTxt": SearchTxt, "StationId": StationId };
//jsonPost("/wsService/CommonQueryHandler.ashx?type=" + _type, params,
if ($.trim(params.stationName) != "请选择") {
autocompletePost(_url,
params,
function(response) {
makeContAndShow(response.data, params.ids);
},
function() {});
bigAutocomplete.holdText = $this.val();
chuangetext = searchTxt; var config = $this.data("config"); var offset = $this.offset();
$bigAutocompleteContent.width(config.width);
var h = $this.outerHeight() - 1;
$bigAutocompleteContent.css({ "top": offset.top + h, "left": offset.left }); }
} //输入框keydown事件
$this.keydown(function(event) {
switch (event.keyCode) {
case 40: //向下键
mate = "1";
if ($bigAutocompleteContent.css("display") == "none") return; var $nextSiblingTr = $bigAutocompleteContent.find(".ct");
if ($nextSiblingTr.length <= 0) { //没有选中行时,选中第一行
$nextSiblingTr = $bigAutocompleteContent.find("tr:first");
} else {
$nextSiblingTr = $nextSiblingTr.next();
}
$bigAutocompleteContent.find("tr").removeClass("ct"); if ($nextSiblingTr.length > 0) { //有下一行时(不是最后一行)
$nextSiblingTr.addClass("ct"); //选中的行加背景
//$this.val($nextSiblingTr.find("div:last").html());//选中行内容设置到输入框中
//onDataSelected($nextSiblingTr.find("div:last").html());
var data = [];
var tdthis = $("td", $nextSiblingTr[0]);
for (var i = 0; i < $(tdthis).length; i++) {
data.push($(tdthis[i]).text());
}
onDataSelected(data);
//div滚动到选中的行,jquery-1.6.1 $nextSiblingTr.offset().top 有bug,数值有问题
$bigAutocompleteContent.scrollTop($nextSiblingTr[0].offsetTop -
$bigAutocompleteContent.height() +
$nextSiblingTr.height()); } else {
$this.val(bigAutocomplete.holdText); //输入框显示用户原始输入的值
}
chuangetext = ""; break;
case 38: //向上键
mate = "1";
if ($bigAutocompleteContent.css("display") == "none") return; var $previousSiblingTr = $bigAutocompleteContent.find(".ct");
if ($previousSiblingTr.length <= 0) { //没有选中行时,选中最后一行行
$previousSiblingTr = $bigAutocompleteContent.find("tr:last");
} else {
$previousSiblingTr = $previousSiblingTr.prev();
}
$bigAutocompleteContent.find("tr").removeClass("ct"); if ($previousSiblingTr.length > 0) { //有上一行时(不是第一行)
$previousSiblingTr.addClass("ct"); //选中的行加背景
//$this.val($previousSiblingTr.find("div:last").html());//选中行内容设置到输入框中
//onDataSelected($previousSiblingTr.find("div:last").html());
var data = [];
var tdthis = $("td", $previousSiblingTr[0]);
for (var i = 0; i < $(tdthis).length; i++) {
data.push($(tdthis[i]).text());
}
onDataSelected(data); //div滚动到选中的行,jquery-1.6.1 $$previousSiblingTr.offset().top 有bug,数值有问题
$bigAutocompleteContent.scrollTop($previousSiblingTr[0].offsetTop -
$bigAutocompleteContent.height() +
$previousSiblingTr.height());
} else {
$this.val(bigAutocomplete.holdText); //输入框显示用户原始输入的值 }
chuangetext = "";
break; case 27: //ESC键隐藏下拉框
queryData = [];
bigAutocomplete.hideAutocomplete();
chuangetext = "";
break;
}
}); //输入框keyup事件
$this.keyup(function(event) {
var k = event.keyCode;
var ctrl = event.ctrlKey;
var isFunctionalKey = false; //按下的键是否是功能键
for (var i = 0; i < bigAutocomplete.functionalKeyArray.length; i++) {
if (k == bigAutocomplete.functionalKeyArray[i]) {
isFunctionalKey = true;
break;
}
}
var searchTxt = $(this).val();
if (searchTxt == "" || searchTxt == null) {
chuangetext = "";
} //k键值不是功能键或是ctrl+c、ctrl+x时才触发自动补全功能
if (!isFunctionalKey && (!ctrl || (ctrl && k == 67) || (ctrl && k == 88))) {
//var config = $this.data("config"); //var offset = $this.offset();
//$bigAutocompleteContent.width(config.width);
//var h = $this.outerHeight() - 1;
//$bigAutocompleteContent.css({ "top": offset.top + h, "left": offset.left }); //var data = config.data;
//var url = config.url;
var keyword_ = $.trim($this.val());
if (keyword_ == null || keyword_ == "") {
bigAutocomplete.hideAutocomplete();
return;
}
//请求json
//if(data != null && $.isArray(data) ){
// var data_ = new Array();
// for(var i=0;i<data.length;i++){
// if(data[i].title.indexOf(keyword_) > -1){
// data_.push(data[i]);
// }
// } // makeContAndShow(data_);
//} else
// if (url != null && url != "") {//ajax请求数据
// $.post(url,{keyword:keyword_},function(result){
// makeContAndShow(result.data)
// },"json")
//} //$.ajax({
// type: 'POST',
// url: '/MyServer2.ashx?q=' + $("#tt").val(),
// //data: data,
// success: function (data) {
// console.log(data);
// makeContAndShow(JSON.parse(data));
// } //}); //
//var station = $("#dropAcceptStation").val();
//if (station == 0)
// return; //var params = {
// SearchTxt: $("#" + _input_id).val(),
// StationId: station
//}; //if (searchTxt != chuangetext) {
// var params = null;
// params = $.extend({}, _options.queryParams, { "SearchTxt": searchTxt });
// //console.log(params)
// //var params = { "SearchTxt": SearchTxt, "StationId": StationId };
// //jsonPost("/wsService/CommonQueryHandler.ashx?type=" + _type, params,
// if ($.trim(params.stationName) !="请选择") {
// jsonPost(_url, params,
// function (response) {
// makeContAndShow(response.data, params.ids);
// }, function () { });
// bigAutocomplete.holdText = $this.val();
// chuangetext = searchTxt;
// }
//} }
//回车键
if (k == 13) {
mate = "1";
var callback_ = $this.data("config").callback;
if ($bigAutocompleteContent.css("display") != "none") {
if (callback_ && $.isFunction(callback_)) {
callback_($bigAutocompleteContent.find(".ct").data("jsonData"));
}
bigAutocomplete.hideAutocomplete();
}
} }); //组装下拉框html内容并显示 拼接一代
/* function makeContAndShow(data_,type) { //console.log(data_);
if (data_ == null || data_.length <= 0) {
$bigAutocompleteContent.html('');
return;
} var cont = "<table><tbody>"; for (var i = 0; i < data_.length; i++) {
//cont += "<tr><td class='demo-td'><div><div class='demo-top'>" + data_[i] + "</div></td></tr>";
cont += "<tr dat=" + data_[i] + ">";
var data_array = new Array();
if (data_[i] != null) {
data_array = data_[i].split("^");
}
for (var j = 0; j < data_array.length; j++) {
//cont += "<td class='demo-td'><div><div class='demo-top'>" + data_array[j] + "</div></td>";
cont += "<td class='demo-td'>" + data_array[j] + "</td>";
}
cont += "</tr>";
} cont += "</tbody></table>"; $bigAutocompleteContent.html(cont);
$bigAutocompleteContent.show(); //每行tr绑定数据,返回给回调函数
$bigAutocompleteContent.find("tr").each(function (index) {
$(this).data("jsonData", data_[index]);
})
}
*/ //组装下拉框html内容并显示 拼接二代
function makeContAndShow(data, ids) { if (data == null || data.length <= 0) {
$bigAutocompleteContent.html('');
return;
}
queryData = data; //给赋值
var cont = "<table><tbody>";
for (var i = 0; i < data.length; i++) {
cont += "<tr";
if (typeof _options.onAssemblyRow == "function" && _options.onAssemblyRow(data[i])) {
cont += " style='background:#f2a2a2'";
}
cont += ">";
for (var j = 0; j < data[i].length; j++) {
if (j > ((data[i].length - 1) - ids)) {
cont += "<td class='demo-td'style='display:none;'>" + data[i][j] + "</td>";
} else {
cont += "<td class='demo-td'>" + data[i][j] + "</td>";
} }
cont += "</tr>";
}
cont += "</tbody></table>"; $bigAutocompleteContent.html(cont);
$bigAutocompleteContent.show(); //每行tr绑定数据,返回给回调函数
$bigAutocompleteContent.find("tr").each(function(index) {
$(this).data("jsonData", data[index]);
});
} } //隐藏下拉框
this.hideAutocomplete = function() {
var $bigAutocompleteContent = $("#bigAutocompleteContent");
if ($bigAutocompleteContent.css("display") != "none") {
$bigAutocompleteContent.find("tr").removeClass("ct");
$bigAutocompleteContent.hide();
judge(); }
chuangetext = "";
queryData = [];
}
//智能提示数据不为空判断操作
function judge() {
if (chuangetext != "") {
//if (queryData.length == 1) { for (var i = 0; i < queryData.length; i++) {
for (var j = 0; j < queryData[i].length; j++) {
if (queryData[i][j] == chuangetext) {
mate = "1";
//console.log("yc_" + mate);
onDataSelected(queryData[i]);
return;
}
}
//} } }
}
}; $.fn.bigAutocomplete = bigAutocomplete.autocomplete; window.onresize = function() {
bigAutocomplete.hideAutocomplete(); }
})(jQuery);
var _required = false;//是否提示
var mate = '';//提示变量状态 0:* 1:提示语 2:鼠标移上
var _input_id = '';
var _type = '';
var _options = {};
var _url = "/wsService/Query.ashx?type=Process";
var chuangetext = "";
function autocomplete(input_id, options, hint) {
_required = false;
mate = "0";
if (hint != undefined && hint == true) {
_required = true;
}
_input_id = input_id;
_options = options;
if (typeof _options.queryParams.ids == "undefined") {
_options.queryParams.ids = "1";
}
//bigAutocomplete.currentInputText = $this; var width = $("#" + input_id).width() + 5; $("#" + input_id).bigAutocomplete({
Width: width,
data: [],
callback: function (data) {
}
}); } function onDataSelected(data) {
if (typeof _options.setData == "function") {
_options.setData(data);
}
} //获取浏览器版本号
var userAgent = window.navigator.userAgent,
rMsie = /(msie\s|trident.*rv:)([\w.]+)/,
rFirefox = /(firefox)\/([\w.]+)/,
rOpera = /(opera).+version\/([\w.]+)/,
rChrome = /(chrome)\/([\w.]+)/,
rSafari = /version\/([\w.]+).*(safari)/;
function uaMatch(ua) {
var match = rMsie.exec(ua);
if (match != null) {
return { browser: "IE", version: match[2] || "0" };
}
var match = rFirefox.exec(ua);
if (match != null) {
return { browser: match[1] || "", version: match[2] || "0" };
}
var match = rOpera.exec(ua);
if (match != null) {
return { browser: match[1] || "", version: match[2] || "0" };
}
var match = rChrome.exec(ua);
if (match != null) {
return { browser: match[1] || "", version: match[2] || "0" };
}
var match = rSafari.exec(ua);
if (match != null) {
return { browser: match[2] || "", version: match[1] || "0" };
}
if (match != null) {
return { browser: "", version: "0" };
}
};
//获取浏览器版本----
var ieVersion = false;//input框绑定事件状态
var browser = "";
var version = "";
var browserMatch = uaMatch(userAgent.toLowerCase()); if (browserMatch.browser) {
browser = browserMatch.browser;
version = browserMatch.version;
if (browser == "IE") {
var idnumber = version.split(".")[0];
if (idnumber == "8") {
ieVersion = true;
}
}
} //根据浏览器版本 input绑定事件
function inputBindQuery(id, fun) { if (ieVersion == false) {
//ie高版本绑定input值改变事件
var isFocus = false;
var cpLock = false;
$('#' + id).on('compositionstart',
function () {
cpLock = true;
});
$('#' + id).on('compositionend',
function () {
isFocus = $("#" + id).is(":focus");
cpLock = false;
if (isFocus) {
fun();
}
});
$('#' + id).on('input',
function () {
isFocus = $("#" + id).is(":focus");
if (!cpLock) {
if ($('#' + id).val() != "") {
if (isFocus) {
fun();
}
}
}
});
} else {
//ie8低版本绑定
$("#" + id).on("textchange",
function (parameters) {
fun();
});
} }
智能提示引用JS 内嵌ajax请求handler
/// <summary>
/// 智能搜索Handler
/// </summary>
public class Query : PageBaseHandler
{ protected override void doRequest(HttpContext context)
{
Process();
}
private void Process()
{
try
{
string[,] outData = null;
var sortKey = default(QueryTypeKey);
string errMsg = null;
var columnList = new List<QueryTypeKey>();
var columns = Request.Form["columns"];//列头,以逗号隔开
var sortField = Request.Form["sorts"];
var queryType = Request.Form["queryType"];
var searchKey = Request.Form["searchKey"];
var stationCode = Request.Form["stationCode"];
var stationName = Request.Form["stationName"];
var paramType = Request.Form["paramType"];
var coList = columns.Split(',');
var qType = (QueryType)Convert.ToInt16(Request.Form["queryType"]);
var extParam = Request.Form["extParam"];
/// sortKey=string.IsNullOrEmpty(sortField)?sortKey:()Convert.to
//转换排序列
var qtks = Enum.GetNames(typeof(QueryTypeKey));
if (!string.IsNullOrEmpty(sortField))
{
foreach (var e in qtks)
{
if (e == sortField)
{
//var res2 = default(QueryTypeKey);
Enum.TryParse(e, out sortKey);
break;
//sortKey=re
}
}
}
//转换搜索列
foreach (var t in coList)
{
// var qtks = Enum.GetNames(typeof(QueryTypeKey));
foreach (var e in qtks)
{
if (t == e)
{
var res = default(QueryTypeKey);
Enum.TryParse(t, out res);
columnList.Add(res);
}
}
} //bool result = ZT.RemotingProxyService.RemotingProxy.Query().Query(qType, searchKey,
// columnList, ref outData, sortKey, ref errMsg);
var qc = new QueryCondition()
{
QueryType = qType,
SearchContext = searchKey,
OutColumns = columnList,
StationCode = stationCode,
StationName = stationName,
ParamType = paramType,
SortKey = sortKey,
ExtParam = extParam,
CorpId = userInfo.CorpId
}; bool result = ZT.RemotingProxyService.RemotingProxy.GetIntellQueryService().Query(qc, ref outData, ref errMsg);
if (result)
{
Response.Write(jsonString(statusCode.success, Message, outData));
}
else
{
Response.Write(jsonString(statusCode.fail, errMsg));
}
}
catch (Exception ex)
{
Response.Write(jsonString(statusCode.fail, ex.Message));
}
}
}
Handler
后续 Handler Http请求Remotting代码请看下一篇: