智能提示含查詢多列(html+JS+handler+ HttpRemoting)一、html示列 加 JS加 請求 Handler

来源:https://www.cnblogs.com/Tcwangyu/archive/2018/04/12/8810426.html
-Advertisement-
Play Games

1 <html> 2 <head> 3 </head> 4 <body> 5 <form id="recordform" name="recordform" autocomplete="off"> 6 <table cellpadding="0" cellspacing="0" class="tab ...


 1 <html>
 2 <head>
 3 </head>
 4 <body>
 5     <form id="recordform" name="recordform" autocomplete="off">
 6 <table cellpadding="0" cellspacing="0" class="tablepadding">
 7                         <%--                        <tr>
 8                             <td rowspan="7" style="width: 40%;">
 9                                 <select size="4" name="lboxReceive" id="lboxReceive" tabindex="-1" style="width: 100%; height: 90%;">
10                                 </select>
11                             </td>
12                         </tr>--%>
13                         <tr>
14                             <th>收貨人:</th>
15                             <td>
16                                 <input id="txtReceiveName" name="txtReceiveName" type="text" class="form-control required" paihang /><span class="required"></span></td>
17                         </tr>
18                         <tr>
19                             <th>手 機:</th>
20                             <td>
21                                 <input id="txtReceiveHand" name="txtReceiveHand" type="text" class="form-control" paihang /></td>
22                         </tr>
23                         <tr>
24                             <th>電 話:</th>
25                             <td>
26                                 <input id="txtReceiveTel" name="txtReceiveTel" type="text" class="form-control" paihang /></td>
27                         </tr>
28                         <tr>
29                             <th>單 位:</th>
30                             <td>
31                                 <input id="txtReceiveCorp" name="txtReceiveCorp" maxlength="200" type="text" class="form-control" paihang /></td>
32                         </tr>
33                         <tr>
34                             <th>地 址:</th>
35                             <td>
36                                 <input id="txtReceiveAddress" name="txtReceiveAddress" maxlength="200" type="text" class="form-control" paihang /></td>
37                         </tr>
38                         <tr>
39                             <th>&nbsp;</th>
40                             <td>&nbsp;</td>
41                         </tr>
42                     </table>
43  </form>
44 <script type="text/javascript">
45         $(function () {
46 inputBindQuery("txtSendName", txtNamechange);
47 });
48  function txtNamechange() {
49             MessageError = MessageError + 1;
50             $("#txtSendName_Id").val("");//清空發貨方id
51             var stationName = $("#dropAcceptStation").find("option:selected").text().trim();
52             if (stationName !== "請選擇") {
53                 var queryParams = {
54                     "columns": "<%=QueryTypeKey.發貨方_發貨方%>,<%=QueryTypeKey.發貨方_聯繫人%>,<%=QueryTypeKey.發貨方_手機%>,<%=QueryTypeKey.發貨方_電話%>,<%=QueryTypeKey.發貨方_單位%>,<%=QueryTypeKey.發貨方_地址%>",
55                     "sorts": "<%=QueryTypeKey.發貨方_發貨方%>",
56                     "queryType": "<%=(int)QueryType.CustomerShipperInfo%>",
57                     "searchKey": $("#txtSendName").val(),
58                     "stationName": stationName
59                 };
60                 var options = { "queryParams": queryParams };
61                 options.setData = setData;
62                 autocomplete("txtSendName", options);
63             } else {                
64                 if (MessageError===1) {
65                     alert("請先選擇攬收站點!");
66                 }
67             }
68         };
69 //選擇下拉框內容後回調填充方法
70  function setData(dt) {
71             $("#txtSendName").val(dt[0]);
72             $("#txtSendLinkUser").val(dt[1]);
73             $("#txtSendHand").val(dt[2]);
74             $("#txtSendTel").val(dt[3]);
75             $("#txtSendCorp").val(dt[4]);
76             $("#txtSendAddress").val(dt[5]);
77             $("#txtSendName_Id").val(dt[6]);
78             //設置收貨方為輸入項
79             $("#txtReceiveName").focus();
80             $("#txtReceiveName").val(dt[0]);
81             txtNamechange4();
82             $("#txtReceiveName").val("");
83         };
84     </script>
85 </body>
86 </html>
智能提示html 代碼
  1 var new_element = document.createElement("script");
  2 new_element.setAttribute("type", "text/javascript");
  3 new_element.setAttribute("src", "/content/bjui/plugins/bootstrap.min.js");
  4 document.body.appendChild(new_element);
  5 /**
  6          * jQuery "splendid textchange" plugin
  7          * http://benalpert.com/2013/06/18/a-near-perfect-oninput-shim-for-ie-8-and-9.html
  8          *為了適應ie 8 9 不觸發彈框
  9          * (c) 2013 Ben Alpert, released under the MIT license
 10          */
 11 
 12 (function ($) {
 13 
 14     var testNode = document.createElement("input");
 15     var isInputSupported = "oninput" in testNode &&
 16         (!("documentMode" in document) || document.documentMode > 9);
 17 
 18     var hasInputCapabilities = function (elem) {
 19         // The HTML5 spec lists many more types than `text` and `password` on
 20         // which the input event is triggered but none of them exist in IE 8 or
 21         // 9, so we don't check them here.
 22         // TODO: <textarea> should be supported too but IE seems to reset the
 23         // selection when changing textarea contents during a selectionchange
 24         // event so it's not listed here for now.
 25         return elem.nodeName === "INPUT" &&
 26             (elem.type === "text" || elem.type === "password");
 27     };
 28 
 29     var activeElement = null;
 30     var activeElementValue = null;
 31     var activeElementValueProp = null;
 32 
 33     /**
 34      * (For old IE.) Replacement getter/setter for the `value` property that
 35      * gets set on the active element.
 36      */
 37     var newValueProp = {
 38         get: function () {
 39             return activeElementValueProp.get.call(this);
 40         },
 41         set: function (val) {
 42             activeElementValue = val;
 43             activeElementValueProp.set.call(this, val);
 44         }
 45     };
 46 
 47     /**
 48      * (For old IE.) Starts tracking propertychange events on the passed-in element
 49      * and override the value property so that we can distinguish user events from
 50      * value changes in JS.
 51      */
 52     var startWatching = function (target) {
 53         activeElement = target;
 54         activeElementValue = target.value;
 55         activeElementValueProp = Object.getOwnPropertyDescriptor(
 56             target.constructor.prototype, "value");
 57 
 58         Object.defineProperty(activeElement, "value", newValueProp);
 59         activeElement.attachEvent("onpropertychange", handlePropertyChange);
 60     };
 61 
 62     /**
 63      * (For old IE.) Removes the event listeners from the currently-tracked
 64      * element, if any exists.
 65      */
 66     var stopWatching = function () {
 67         if (!activeElement) return;
 68 
 69         // delete restores the original property definition
 70         delete activeElement.value;
 71         activeElement.detachEvent("onpropertychange", handlePropertyChange);
 72 
 73         activeElement = null;
 74         activeElementValue = null;
 75         activeElementValueProp = null;
 76     };
 77 
 78     /**
 79      * (For old IE.) Handles a propertychange event, sending a textChange event if
 80      * the value of the active element has changed.
 81      */
 82     var handlePropertyChange = function (nativeEvent) {
 83         if (nativeEvent.propertyName !== "value") return;
 84 
 85         var value = nativeEvent.srcElement.value;
 86         if (value === activeElementValue) return;
 87         activeElementValue = value;
 88 
 89         $(activeElement).trigger("textchange");
 90     };
 91 
 92     if (isInputSupported) {
 93         $(document)
 94             .on("input", function (e) {
 95                 // In modern browsers (i.e., not IE 8 or 9), the input event is
 96                 // exactly what we want so fall through here and trigger the
 97                 // event...
 98                 if (e.target.nodeName !== "TEXTAREA") {
 99                     // ...unless it's a textarea, in which case we don't fire an
100                     // event (so that we have consistency with our old-IE shim).
101                     $(e.target).trigger("textchange");
102                 }
103             });
104     } else {
105         $(document)
106             .on("focusin", function (e) {
107                 // In IE 8, we can capture almost all .value changes by adding a
108                 // propertychange handler and looking for events with propertyName
109                 // equal to 'value'.
110                 // In IE 9, propertychange fires for most input events but is buggy
111                 // and doesn't fire when text is deleted, but conveniently,
112                 // selectionchange appears to fire in all of the remaining cases so
113                 // we catch those and forward the event if the value has changed.
114                 // In either case, we don't want to call the event handler if the
115                 // value is changed from JS so we redefine a setter for `.value`
116                 // that updates our activeElementValue variable, allowing us to
117                 // ignore those changes.
118                 if (hasInputCapabilities(e.target)) {
119                     // stopWatching() should be a noop here but we call it just in
120                     // case we missed a blur event somehow.
121                     stopWatching();
122                     startWatching(e.target);
123                 }
124             })
125 
126             .on("focusout", function () {
127                 stopWatching();
128             })
129 
130             .on("selectionchange keyup keydown", function () {
131                 // On the selectionchange event, e.target is just document which
132                 // isn't helpful for us so just check activeElement instead.
133                 //
134                 // 90% of the time, keydown and keyup aren't necessary. IE 8 fails
135                 // to fire propertychange on the first input event after setting
136                 // `value` from a script and fires only keydown, keypress, keyup.
137                 // Catching keyup usually gets it and catching keydown lets us fire
138                 // an event for the first keystroke if user does a key repeat
139                 // (it'll be a little delayed: right before the second keystroke).
140                 // Other input methods (e.g., paste) seem to fire selectionchange
141                 // normally.
142                 if (activeElement && activeElement.value !== activeElementValue) {
143                     activeElementValue = activeElement.value;
144                     $(activeElement).trigger("textchange");
145                 }
146             });
147     }
148 
149 })(jQuery);
150 
151 (function ($) {
152     //document.write('<script type="text/javascript" src="/content/common/js/modules/jquerySplendidTextchange.js">');
153     document.write('<style>' +
154         ' .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; }' +
155         '.bigautocomplete-layout table{border-collapse:collapse;border-spacing:0;background:none repeat scroll 0 0 #FFFFFF;width:100%;cursor:default;}' +
156         '.bigautocomplete-layout table tr:nth-child(odd){background:none repeat scroll 0 0 #fbf6f6;}' +
157         '.bigautocomplete-layout table tr:nth-child(even){background:none repeat scroll 0 0 #FFFFFF;}' +
158         '.bigautocomplete-layout table tr td{border-top: 1px solid #EAEAEA;border-left: 1px solid #EAEAEA;text-align:center;padding:0 5px;}' +
159         '.bigautocomplete-layout table tr td:nth-child(1){border-left: 0px;}' +
160         '.bigautocomplete-layout .ct{background:none repeat scroll 0 0 #D2DEE8 !important;}' +
161         '.bigautocomplete-layout div{word-wrap:break-word;word-break:break-all;padding:1px 5px;}' +
162         '</style>');
163 
164     var bigAutocomplete = new function () {
165         
166         this.currentInputText = null; //目前獲得游標的輸入框(解決一個頁面多個輸入框綁定自動補全功能)
167         this.functionalKeyArray = [
168             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,
169             121, 122, 123, 144, 19, 145, 40, 38, 27
170         ]; //鍵盤上功能鍵鍵值數組
171         this.holdText = null; //輸入框中原始輸入的內容
172         var queryData = []; //數據集合
173         //初始化插入自動補全div,併在document註冊mousedown,點擊非div區域隱藏div
174         this.init = function() {
175             queryData = [];
176             $("body").append("<div id='bigAutocompleteContent' class='bigautocomplete-layout'></div>");
177             //$("#" + _input_id).blur(function () {
178             //    bigAutocomplete.hideAutocomplete();
179             //});
180             
181             $(document).bind('mousedown',
182                 function(event) {
183                     var $target = $(event.target);
184                     if ((!($target.parents().andSelf().is('#bigAutocompleteContent'))) &&
185                         (!$target.is(bigAutocomplete.currentInputText))) {
186                         bigAutocomplete.hideAutocomplete();
187                     }
188                 });
189 
190             //滑鼠懸停時選中當前行
191             $("#bigAutocompleteContent").delegate("tr",
192                 "mouseover",
193                 function () {
194                     mate = "1";
195                     $("#bigAutocompleteContent tr").removeClass("ct");
196                     $(this).addClass("ct");
197                 }).delegate("tr",
198                 "mouseout",
199                 function() {
200                     $("#bigAutocompleteContent tr").removeClass("ct");
201                 });
202 
203 
204             //單擊選中行後,選中行內容設置到輸入框中,並執行callback函數
205             $("#bigAutocompleteContent").delegate("tr",
206                 "click",
207                 function (tr) {
208                     mate = "1";
209                     hintfun();
210                     //bigAutocomplete.currentInputText.val($(this).find("div:last").html());
211                     //onDataSelected($(this).find("div:last").html());
212                     var data = [];
213                     var tdthis = $("td", $(this)[0]);
214                     for (var i = 0; i < $(tdthis).length; i++) {
215                         data.push($(tdthis[i]).text());
216                     }
217                     onDataSelected(data);
218                     //var callback_ = bigAutocomplete.currentInputText.data("config").callback;
219                     var callback_ = bigAutocomplete.currentInputText;
220                     if ($("#bigAutocompleteContent").css("display") != "none" && callback_ && $.isFunction(callback_)) {
221                         
222                         callback_(data);
223 
224                     }
225                     chuangetext = "";
226 
227                     bigAutocomplete.hideAutocomplete();
228                 });
229 
230         }
231 
232         //提示方法
233         function hintfun() {
234             //if (mate == "0"&&_required==true) {
235             //    bigAutocomplete.hideAutocomplete();
236             //    if (mate == "0") {
237             //        //$("#" + _input_id).val("");
238             //        //$("#" + _input_id).parent().find("span").html("請從智能提示中選擇!");
239             //        //$("#" + _input_id).parent().find("span").html("<span class='hintSpan'></span>");
240             //        if ($("#" + _input_id).parent().find("span").hasClass("beHint")==false)
241             //        {
              
您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 寫入文本文件 1. 關聯讀入的文件,使用Reader 和 FileReader 2. 關聯寫出的文件,使用Writer和 FileWriter 3. 創建緩衝 char數組,用於接收讀取到的文本信息 4. 將文本讀入到 緩衝數組(buff)中 5. 輸出讀取到的文本信息 6. 寫出讀取到的文件 7. ...
  • 練習 4.12: 流行的web漫畫服務xkcd也提供了JSON介面。例如,一個 https://xkcd.com/571/info.0.json 請求將返回一個很多人喜愛的571編號的詳細描述。 下載每個鏈接(只下載一次)然後創建一個離線索引。編寫一個xkcd工具,使用這些離線索引,列印和命令行輸入 ...
  • 在Kotlin中 使用js 函數 ...
  • 在一對多或者多對多的時候。如果通過一的一方取獲得多的一方的數據。除了第一次查詢表的數據以外。每獲得一條多的一方的數據就查詢一次。 如:通過學生表的記錄查詢成績表的記錄。 一個學生就查詢一次,50個學生就查詢50次。 如果需要查詢50個學生的成績,需要查詢資料庫的次數為 第一次查詢學生的記錄+50次查 ...
  • 概述 UWP Community Toolkit Extensions 中有一個為可視元素提供的擴展 - VisualExtensions,本篇我們結合代碼詳細講解 VisualExtensions 的實現。 VisualExtensions 為可視元素提供了一種簡單的在 XAML 中修改通用屬性的 ...
  • 搭建Spring: 3、演示IOC操作,在Service中調用Dao中的方法 UserDao.java package com.zzb.www.dao public class UserDao{ public void add(){ System.out.println("dao........") ...
  • 我們只知道靜態成員的用法,比如調用一個靜態方法要用類名去點出來,比如Math.Max(),但是為什麼是這樣調用呢?為什麼靜態構造函數不能有訪問修飾符?為什麼靜態構造函數沒有參數?靜態函數的執行時間又是什麼時候?為什麼? 在面向對象中,萬物皆對象。其中就有一種對象叫作類型對象,類型對象就是我們創建一個 ...
  • 1 /// <summary> 2 /// 智能查詢類型 3 /// </summary> 4 5 public enum QueryType : byte 6 { 7 /// <summary> 8 /// 發貨方聯繫人信息 9 /// </summary> 10 [DataMappingAttr ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...