posts - 165, comments - 198, trackbacks - 0, articles - 1
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理
          問題: 用戶在 WEB 中輸入 機(jī)車 人員 等項(xiàng) 頁面會(huì)根據(jù)當(dāng)前字符給出選擇提示
          解決:scriptaculous javascript工具包的 Autocompleter.Local


          與圖對(duì)應(yīng)代碼:
          <TD><html:checkbox?property="value(Yloco)"?value="Y"/>機(jī)車</TD>
          <TD><input?id="loco"?type="text"?name="value(loco)"?size="20"?value="${map['loco']}"?onkeyup="getData();"></TD>
          <div?id="locoupdate"?style="display:none;border:1px?solid?black;background-color:white;height:150px;overflow:auto;"></div>????

          javascript 處理方法
          ?? var arr = new Array();
          ?? //關(guān)鍵方法
          scriptaculous框架 提供方法
          ?? //要使用 此方法 先到入 prototype.js? effects.js?? controls.js
          ?? new Autocompleter.Local('loco','locoupdate',
          ? ?? ??? ??? ??? ??? ?arr, { tokens: new Array(',','\n'), fullSearch: true, partialSearch: true});
          ??
          function?getData(){???
          ??? ?? ?? ? //得到 字符數(shù)組 str,str,str.....
          ????????????
          var?url?=?"/jczb/jczb/meanwhileDiary.do?method=loco&par="+document.getElementById("loco").value;????
          ????????????
          new?Ajax.Request(
          ????????????????????url,
          ????????????????????{
          ????????????????????????method:?'get',
          ????????????????????????onComplete:?action??????????????
          ????????????????});????
          ????}
          ????
          function?action(req){
          ????????????
          var?str?=?req.responseText.split(",")?;
          ????????????
          while(!arr.length==0){
          ????????????????arr.pop();
          ????????????}

          ????????????
          for(?var?jj=0;jj<str.length-1;jj++?){
          ????????????????????arr[jj]?
          =?str[jj];
          ????????????}
          ????????}



          完整jsp


          ?
          心得:多看書 是有幫助的

          評(píng)論

          # re: ajax 的 輸入選擇 (同google&讀數(shù)據(jù)庫)   回復(fù)  更多評(píng)論   

          2007-07-26 19:33 by dfjinn
          這種方法是每輸一個(gè)字就查詢一次數(shù)據(jù)庫,如果對(duì)一個(gè)打字速度快的用戶,那勢(shì)必會(huì)對(duì)數(shù)據(jù)造成較大的壓力。

          # re: ajax 的 輸入選擇 (同google&讀數(shù)據(jù)庫) [未登錄]  回復(fù)  更多評(píng)論   

          2007-07-30 09:50 by G_G
          我寫到這份上了 應(yīng)該可以安你的想法改 是很 好改的了
          主站蜘蛛池模板: 长治县| 云浮市| 丰都县| 新宁县| 开封县| 昔阳县| 泸西县| 莆田市| 天柱县| 宜兰县| 永春县| 湄潭县| 贵港市| 喀什市| 乌兰浩特市| 芒康县| 康保县| 枣庄市| 安阳县| 鹤庆县| 渝北区| 湖北省| 齐河县| 额尔古纳市| 诏安县| 东乌珠穆沁旗| 青浦区| 建湖县| 吴旗县| 新民市| 鲁甸县| 南靖县| 肇庆市| 绍兴市| 延安市| 嘉义市| 阜新| 永新县| 武定县| 托克逊县| 延寿县|