HelloWorld 善戰者,求之于勢,不責于人;故能擇人而任勢。

          知止而后有定,定而后能靜,靜而后能安,安而后能慮,慮而后能得。物有本末,事有終始。知所先后,則近道矣。

            BlogJava :: 首頁 ::  :: 聯系 ::  :: 管理 ::
            167 隨筆 :: 1 文章 :: 40 評論 :: 0 Trackbacks

          function suggest(src,confield,convalue,operation,thisObj) {
          var str = thisObj.value;
          var key = window.event.keyCode;
          if (key == 40 || key == 38) {
             if (isNull(thisObj.value2)) {
              thisObj.value2 = thisObj.value;
             }
             var suggestDiv = document.getElementById(thisObj.name+"_suggest");
             if (!isNull(suggestDiv)) {
              var divArr = suggestDiv.childNodes;
              var hasIn = false;
              for (var i = 0; i < divArr.length; i++) {
               if(divArr[i].className == "td-across-deep") {
                hasIn = true;
                divArr[i].className = "td-across-low";
                divArr[i].style.backgroundColor = "white";
                if (key == 40) {
                 if (i == divArr.length-1) {
                  thisObj.value = thisObj.value2;
                 } else {
                  divArr[i+1].className = "td-across-deep";
                  divArr[i+1].style.backgroundColor = "";
                  thisObj.value = divArr[i+1].innerText;
                 }
                } else if (key == 38) {
                 if (i == 0) {
                  thisObj.value = thisObj.value2;
                 } else {
                  divArr[i-1].className = "td-across-deep";
                  divArr[i-1].style.backgroundColor = "";
                  thisObj.value = divArr[i-1].innerText;
                 }
                }
                break;
               }
              }
              if (!hasIn) {
               var i = 0;
               if (key == 38) {
                i = divArr.length-1;
                suggestDiv.scrollTop = 200;
               } else {
                suggestDiv.scrollTop = 0;
               }
               divArr[i].className = "td-across-deep";
               divArr[i].style.backgroundColor = "";
               thisObj.value = divArr[i].innerText;
              } else {
               key == 40 ? (suggestDiv.scrollTop +=17) : (suggestDiv.scrollTop -=17);
              }
              return true;
             }
          }
          var dbonclick = document.body.onclick
          document.body.onclick = function() {
             if(!isNull(dbonclick))
              dbonclick();
             var arr = document.getElementsByTagName("div");
             if (!isNull(arr))
             for (var i = 0; i < arr.length; i++) {
              if (!isNull(arr[i].name))
              if (arr[i].name.indexOf("suggest") >= 0) {
               document.body.removeChild(arr[i]);
              }
             }
             arr = document.getElementsByTagName("iframe");
             if (!isNull(arr))
             for (var i = 0; i < arr.length; i++) {
              if (!isNull(arr[i].name))
              if (arr[i].name.indexOf("suggest") >= 0) {
               document.body.removeChild(arr[i]);
              }
             }
             thisObj.value2 = null;
          }
          try {
          document.body.onclick();
          } catch (e) {
             alert(e);
          }
          if (key == 13 || key ==   27 || isNull(str) || str.trim() == "" ) {
             return true;
          }
          var h=location.protocol+"http://"+location.host+"/";
               var pn=location.href.substring(h.length);
               pn=pn.substring(0,pn.indexOf("/"));
          var records=thisObj.name.substring(thisObj.name.lastIndexOf("_")+1);
          var fields = confield.split("#");
          var conVal = convalue.split("#");
          var confields = confield.split("#");
          var con = "";
          for (var i = 1; i < conVal.length; ++i) {
             var temp = "&fld"+confields[i]+"=";
             if (conVal[i].substring(0,1) == "&") {
              temp += conVal[i].substring(1);
             } else {
              var valObj = document.all["fld_abm"+parseFloat(conVal[i])+"_"+records];
              if (valObj == null) {
               valObj = document.all["fld_abm"+parseFloat(conVal[i])+"_"+1];
              }
              temp += strTrim(getObjValue(valObj));
             }
             con += temp;
          }
          url="/"+pn+"/FormServlet?act=getSuggest&src="+src+"&field="+confield+con;
               if (operation != null) {
                url += "&operation="+operation;
               }
          while (url.indexOf("#") >=0) {
             url = url.replace("#","_");
          }
               url+="&suggest="+str;
          url = encodeURI(url);
          var ajax = new Ajax(url,"post");
          var divObj = document.all[thisObj.name+"_suggest"];
          var iframeObj = document.createElement("iframe");

          iframeObj.id = thisObj.name+"_suggest_iframe";
          iframeObj.name = thisObj.name+"_suggest_iframe";
          document.body.appendChild(iframeObj);
          if (isNull(divObj)) {
             divObj = document.createElement("DIV");
          }
          divObj.name = thisObj.name+"_suggest";
          divObj.id = thisObj.name+"_suggest";
          divObj.style.border = '1px';
          divObj.isOut = "true";
          divObj.onmouseover = "javascript:this.isOut = 'false'";
          divObj.onmouseout = "javascript:this.isOut = 'true'";
          divObj.style.cursor = "hand";

          document.body.appendChild(divObj);
          divObj.style.position = "absolute";
          ajax.setResponseFun(function(){
             var dom = ajax.getDomDoc();
             if(dom.readyState == 4) {
              var root = dom.documentElement;
              var str = "";
              if (root.childNodes.length == 0) {
               document.body.onclick();
               return true;
              }
              for(var i = 0; i < root.childNodes.length; i++) {
               str+="<div onmouseover='javascript:suggestOver(this);'";
               str+=" onmouseout='javascript:suggestOut(this);' ";
               str+=" onclick='javascript:setSearch(this.innerHTML,\""+thisObj.name+"\");' class='td-across-low' style='background-color:white;'>";
               str+=root.childNodes[i].text+"</div>";
              }
              divObj.innerHTML = str;
              divObj.style.borderBottom = '0.008cm outset ';
              divObj.style.borderRight = '0.008cm outset ';
              divObj.style.borderTop = '0.008cm outset ';
              divObj.style.borderLeft = '0.008cm outset ';
              divObj.style.overflowY = "auto";
              divObj.style.height = divObj.offsetHeight > 300 ? 300 : divObj.offsetHeight;
              var oRect = thisObj.getBoundingClientRect();
              divObj.style.left = oRect.left;
              divObj.style.top = oRect.top + 18;
              divObj.style.width = thisObj.clientWidth+2;
              try {
               var iobj = document.getElementById(thisObj.name+"_suggest_iframe");
               iobj.style.position = "absolute";
               iobj.style.left = divObj.offsetLeft;
               iobj.style.top = divObj.offsetTop;
               iobj.style.height = divObj.offsetHeight;
               iobj.style.width = divObj.offsetWidth;
              } catch(e){}
             }
          });
          ajax.send();
          return true;
          }

          function suggestOver(obj) {
          for(var i = 0; i < obj.parentNode.childNodes.length; i++) {
             obj.parentNode.childNodes[i].className = "td-across-low";  
             obj.parentNode.childNodes[i].style.backgroundColor = "white";
          }
          obj.className = "td-across-deep";
          obj.style.backgroundColor = "";
          }

          function suggestOut(obj) {
          obj.className = "td-across-low";
          obj.style.backgroundColor = "white";
          }

          function setSearch(value,thisObjName) {
          document.all[thisObjName].value = value;
          try {
          document.body.removeChild(document.getElementById(thisObjName+"_suggest_iframe"));
          document.body.removeChild(document.getElementById(thisObjName+"_suggest"));
          } catch (e){}
          }

          function hideSuggest(thisObj) {
          var obj = document.getElementById(thisObj.name+"_suggest");
          if ( isNull(obj) ) {
             return true;
          } else {
             if (obj.isOut == "true") {
              document.body.removeChild(document.getElementById(obj.name+"_suggest_iframe"));
              document.body.removeChild(obj);
             }
          }
          return true;
          }



          </script>

          posted on 2007-08-13 18:56 helloworld2008 閱讀(517) 評論(0)  編輯  收藏 所屬分類: html/javascript/css
          主站蜘蛛池模板: 化隆| 青海省| 岳池县| 南安市| 织金县| 静安区| 宜城市| 邮箱| 海安县| 遂溪县| 甘洛县| 惠来县| 东城区| 丹凤县| 宁南县| 三门峡市| 赤壁市| 连城县| 武夷山市| 建湖县| 和平区| 稻城县| 三明市| 奈曼旗| 牟定县| 慈溪市| 思茅市| 泽州县| 渝中区| 斗六市| 仙居县| 和田县| 丹阳市| 瑞金市| 稻城县| 连平县| 麻栗坡县| 湟源县| 通渭县| 勐海县| 普格县|