第一次搜寻之后,你两个表格的Id重复了
我做了一下没弄出来,下班了,给你传上来看看,希望你能找到解决办法:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>查询信息</title>
<script language="JavaScript" type="text/javascript">
    function search(val){
        //……//不知如何保存数据,
        var info = searchDetail(document.all.tabInfo,val);
        if(info!=""){
          var infos = info.substring(1).split(";");
          var len = infos.length;
          for(var i=0;i<len;i++){
             var row = tabSearch.insertRow(i);
             var cell = row.insertCell();
             cell.innerText = infos[i];
          }
document.all.divSearch.getElementsByTagName("table")[0].setAttribute("id","tabInfo");
          document.all.divInfo.innerHTML = document.all.divSearch.innerHTML;
document.all.divSearch.getElementsByTagName("table")[0].setAttribute("id","tabSearch");
        }
   }
   function searchDetail(o,val){
      var infod = "";
      var len = o.rows.length;
      for(var i=0;i<len;i++){
         if(o.rows(i).cells(0).innerText.indexOf(val)>=0){
            infod += ";"+o.rows(i).cells(0).innerText;
         }
      }
      return infod;
   }
</script>
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" scroll="no">
<input type="text" name="searchValue" onkeydown="if(event.keyCode=='13'){search(this.value);}">
<br>
<div id="divInfo" style="position:absolute;width:100%;height:100%;overflow:auto">
  <table id="tabInfo" border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td>abdc</td>
    </tr>
    <tr>
      <td>abde</td>
    </tr>
    <tr>
      <td>123</td>
    </tr>
  </table>
</div>
<div id="divSearch" style="display:none">
  <table id="tabSearch" border="0" cellpadding="0" cellspacing="0" width="100%">
  </table>
</div>
</body>
</html>

解决方案 »

  1.   

    给你个拼音码的例子:
    你连续输入a,aa,aaa试试<SCRIPT language=vbscript>
    Dim ArrKey(3):ArrKey(0) = "a|20050820|王超":ArrKey(1) = "aa|555|555":ArrKey(2) = "aaa|777|rr":
    </SCRIPT><SCRIPT language=vbscript>
    sIndex = -1
    function KeyChange()
    DisplayKey document.all("yfxm").value
    end function
    function DisplayKey(bh,xm,divSel,sltKey)
    'msgbox("777")
    Dim MyIndex
    dim key
    key = document.all(xm).value
    document.all(sltKey).length = 0
    if Key<>"" then
    MyIndex = Filter(ArrKey, Key)
    count = ubound(MyIndex)
    for i=0 to count
    Set ObjOption = document.CreateElement("option")
    val = Split(MyIndex(i),"|",-1,1)
    ObjOption.Text  = val(2)
    ObjOption.value = val(1)
    document.all(sltKey).add ObjOption
    next
    if window.event.keyCode=38 then
    sIndex = sIndex - 1
    if sIndex<0 then
    sIndex=0
    end if
    document.all(sltKey).selectedIndex=sIndex
    end if
    if window.event.keyCode=40 then
    sIndex = sIndex + 1
    if sIndex>=document.all(sltKey).length then
    sIndex=document.all(sltKey).length -1
    end if
    document.all(sltKey).selectedIndex=sIndex
    end if
    if window.event.keyCode=13 then
    if sIndex>=0 then
    if document.all(sltKey).length>0 then
    document.all(bh).value = document.all(sltKey).item(sIndex).value
    document.all(xm).value = document.all(sltKey).item(sIndex).innerText
    end if
    end if
    document.all(divSel).style.display="none"
    end if
    else
    document.all(divSel).style.display="none"
    end if
    end function
    function NoneDiv(divSel)
    document.all(divSel).style.display="none"
    end function
    </SCRIPT><INPUT class=text id=xm onblur='vbscript:NoneDiv("divSel")' onkeyup='vbscript:DisplayKey "hhh","xm","divSel","sltKey"' maxLength=16 size=8 name=xm>
    <div id=divSel astyle="display:none;">
    <SELECT class=zz size=10 name=sltKey></SELECT>
    </div>
      

  2.   

    楼主,已经解决,看看是不是你想要的效果:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>查询信息</title>
    <script language="JavaScript" type="text/javascript">
        function search(val){
            var info = searchDetail(document.all.tabInfo,val);
            if(info!=""){
              var infos = info.substring(1).split(";");
              var len = infos.length;
              for(var i=0;i<len;i++){
                 var row = tabSearch.insertRow(i);
                 var cell = row.insertCell();
                 cell.innerText = infos[i];
              }
    document.all.divSearch.getElementsByTagName("table")[0].setAttribute("id","tabInfo");
              document.all.divInfo.innerHTML = document.all.divSearch.innerHTML;
    document.all.divSearch.getElementsByTagName("table")[0].setAttribute("id","tabSearch");
    document.all.divSearch.innerHTML = "<table id='tabSearch' border='0' cellpadding='0' cellspacing='0' width='100%'></table>";
            }
       }
       function searchDetail(o,val){
          var infod = "";
          var len = o.rows.length;
          for(var i=0;i<len;i++){
             if(o.rows(i).cells(0).innerText.indexOf(val)>=0){
                infod += ";"+o.rows(i).cells(0).innerText;
             }
          }
          return infod;
       }
    </script>
    </head>
    <body topmargin="0" leftmargin="0" rightmargin="0" scroll="no">
    <input type="text" name="searchValue" onKeyDown="if(event.keyCode=='13'){search(this.value);}">
    <br>
    <div id="divInfo" style="position:absolute;width:100%;height:100%;overflow:auto">
      <table id="tabInfo" border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
          <td>abdc</td>
        </tr>
        <tr>
          <td>abde</td>
        </tr>
        <tr>
          <td>123</td>
        </tr>
      </table>
    </div>
    <div id="divSearch" style="display:none">
      <table id="tabSearch" border="0" cellpadding="0" cellspacing="0" width="100%">
      </table>
    </div>
    </body>
    </html>
      

  3.   

    楼主,已经解决,看看是不是你想要的效果:
    不过友情提醒楼主一下,你这里用的document.all 只有IE支持,建议全换成document.getElementById()这种形式的<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>查询信息</title>
    <script language="JavaScript" type="text/javascript">
        function search(val){
            var info = searchDetail(document.all.tabInfo,val);
            if(info!=""){
              var infos = info.substring(1).split(";");
              var len = infos.length;
              for(var i=0;i<len;i++){
                 var row = tabSearch.insertRow(i);
                 var cell = row.insertCell();
                 cell.innerText = infos[i];
              }
    document.all.divSearch.getElementsByTagName("table")[0].setAttribute("id","tabInfo");
              document.all.divInfo.innerHTML = document.all.divSearch.innerHTML;
    document.all.divSearch.getElementsByTagName("table")[0].setAttribute("id","tabSearch");
    document.all.divSearch.innerHTML = "<table id='tabSearch' border='0' cellpadding='0' cellspacing='0' width='100%'></table>";
            }
       }
       function searchDetail(o,val){
          var infod = "";
          var len = o.rows.length;
          for(var i=0;i<len;i++){
             if(o.rows(i).cells(0).innerText.indexOf(val)>=0){
                infod += ";"+o.rows(i).cells(0).innerText;
             }
          }
          return infod;
       }
    </script>
    </head>
    <body topmargin="0" leftmargin="0" rightmargin="0" scroll="no">
    <input type="text" name="searchValue" onKeyDown="if(event.keyCode=='13'){search(this.value);}">
    <br>
    <div id="divInfo" style="position:absolute;width:100%;height:100%;overflow:auto">
      <table id="tabInfo" border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
          <td>abdc</td>
        </tr>
        <tr>
          <td>abde</td>
        </tr>
        <tr>
          <td>123</td>
        </tr>
      </table>
    </div>
    <div id="divSearch" style="display:none">
      <table id="tabSearch" border="0" cellpadding="0" cellspacing="0" width="100%">
      </table>
    </div>
    </body>
    </html>