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)該可以安你的想法改 是很 好改的了
          主站蜘蛛池模板: 长垣县| 肇州县| 高平市| 藁城市| 双城市| 彭阳县| 祁阳县| 家居| 志丹县| 古交市| 保山市| 西宁市| 定兴县| 邯郸市| 哈尔滨市| 东乡县| 微山县| 金乡县| 新蔡县| 荆州市| 沈阳市| 贵港市| 额济纳旗| 建平县| 镇雄县| 通河县| 彭山县| 勃利县| 东安县| 精河县| 中山市| 尚义县| 南雄市| 景宁| 满洲里市| 珠海市| 怀集县| 富顺县| 通江县| 彝良县| 枞阳县|