lostyue 发表于 2011-12-21 08:44

自己实现的auto complete

<DIV>
<DIV id=codeText class=codeText>
<OL style="PADDING-BOTTOM: 5px; MARGIN: 0px 1px 0px 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 5px" class=dp-css>
<LI><SPAN style="COLOR: #000000"><SPAN style="COLOR: #0000ff">var</SPAN> xmlHttp<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">var</SPAN> popupdiv<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">var</SPAN> nameTable<SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">var</SPAN> nameTableBody<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">var</SPAN> inputfield<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">var</SPAN> otherfield<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">function</SPAN> myinitialization<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">!</SPAN>popupdiv<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;popupdiv <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff0000">document</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">createElement</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"DIV"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nameTable <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff0000">document</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">createElement</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"TABLE"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nameTableBody <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff0000">document</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">createElement</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"TBODY"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nameTable<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">appendChild</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>nameTableBody<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;popupdiv<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">appendChild</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>nameTable<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff0000">document</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">body</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">appendChild</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>popupdiv<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">function</SPAN> setPosition<SPAN style="COLOR: #0000cc">(</SPAN>inputfield<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>popupdiv<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//position<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">var</SPAN> end <SPAN style="COLOR: #0000cc">=</SPAN> inputfield<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">offsetWidth</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">var</SPAN> <SPAN style="COLOR: #ff0000">left</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> calculateOffsetLeft<SPAN style="COLOR: #0000cc">(</SPAN>inputfield<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #0000ff">var</SPAN> <SPAN style="COLOR: #ff0000">top</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> calculateOffsetTop<SPAN style="COLOR: #0000cc">(</SPAN>inputfield<SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">+</SPAN> inputfield<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">offsetHeight</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp; popupdiv<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">style</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">display</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">"block"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp; popupdiv<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">style</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">border</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">"black 1px solid"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp; popupdiv<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">style</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">left</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff0000">left</SPAN> <SPAN style="COLOR: #0000cc">+</SPAN> <SPAN style="COLOR: #ff00ff">"px"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp; popupdiv<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">style</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">top</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff0000">top</SPAN> <SPAN style="COLOR: #0000cc">+</SPAN> <SPAN style="COLOR: #ff00ff">"px"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;popupdiv<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">style</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">width</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">"300px"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;popupdiv<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">style</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">height</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">"200px"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;popupdiv<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">style</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">overflowX</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">"hidden"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;popupdiv<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">style</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">overflowY</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">"auto"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;popupdiv<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">style</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">position</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">"absolute"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;popupdiv<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">style</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">backgroundColor</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">"#FFFAFA"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nameTable<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">style</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">width</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">"100%"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><BR></LI>
<LI><SPAN style="COLOR: #ff9900">/*&nbsp;&nbsp;&nbsp;&nbsp;function sendRequest(){<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputfield = document.getElementById("inputname");<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myinitialization();<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(inputfield.value.length &gt; 0){<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xmlHttp = new XMLHttpRequest();<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xmlHttp.onreadystatechange = handleStateChange;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var queryString = "home?inputname=" + escape(inputfield.value);<BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xmlHttp.open("POST", queryString, true);<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xmlHttp.send();<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clearNames(); <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} */</SPAN><BR></LI>
<LI><BR></LI>
<LI><SPAN style="COLOR: #ff9900">/*&nbsp;&nbsp;&nbsp;&nbsp;function handleStateChange() { <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(xmlHttp.readyState == 4) { <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(xmlHttp.status == 200) {<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//nameTable.focus(); <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setNames(xmlHttp.respon***ML.getElementsByTagName("emsuser"), inputfield);<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else if (xmlHttp.status == 204){ <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clearNames(); <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;}*/</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">function</SPAN> handleStateChange<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">{</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>xmlHttp<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">readyState</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #0000cc">=</SPAN> 4<SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">{</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>xmlHttp<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">status</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #0000cc">=</SPAN> 200<SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//nameTable.focus(); <BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//var inputfield = document.getElementById("associateId"); <BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//var otherfield = document.getElementById("associateName");<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">var</SPAN> myusers <SPAN style="COLOR: #0000cc">=</SPAN> xmlHttp<SPAN style="COLOR: #0000cc">.</SPAN>respon***ML<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">getElementsByTagName</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"emsuser"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>myusers<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">length</SPAN> <SPAN style="COLOR: #0000cc">&gt;</SPAN> 0<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setNames<SPAN style="COLOR: #0000cc">(</SPAN>myusers<SPAN style="COLOR: #0000cc">,</SPAN> inputfield<SPAN style="COLOR: #0000cc">,</SPAN> otherfield<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">else</SPAN><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clearNames<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">function</SPAN> setNames<SPAN style="COLOR: #0000cc">(</SPAN>the_names<SPAN style="COLOR: #0000cc">,</SPAN> inputfield<SPAN style="COLOR: #0000cc">,</SPAN> otherfield<SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">{</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clearNames<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">var</SPAN> <SPAN style="COLOR: #ff0000">size</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> the_names<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">length</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//setOffsets(); <BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setPosition<SPAN style="COLOR: #0000cc">(</SPAN>inputfield<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">var</SPAN> row<SPAN style="COLOR: #0000cc">,</SPAN> cell<SPAN style="COLOR: #0000cc">,</SPAN> txtNode<SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">for</SPAN> <SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">var</SPAN> i <SPAN style="COLOR: #0000cc">=</SPAN> 0<SPAN style="COLOR: #0000cc">;</SPAN> i <SPAN style="COLOR: #0000cc">&lt;</SPAN> <SPAN style="COLOR: #ff0000">size</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> i<SPAN style="COLOR: #0000cc">+</SPAN><SPAN style="COLOR: #0000cc">+</SPAN><SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">var</SPAN> empname <SPAN style="COLOR: #0000cc">=</SPAN> the_names<SPAN style="COLOR: #0000cc">[</SPAN>i<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">getElementsByTagName</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"empname"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">var</SPAN> empid <SPAN style="COLOR: #0000cc">=</SPAN> the_names<SPAN style="COLOR: #0000cc">[</SPAN>i<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">getElementsByTagName</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"empid"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">var</SPAN> nextNode <SPAN style="COLOR: #0000cc">=</SPAN> empname<SPAN style="COLOR: #0000cc">[</SPAN>0<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">firstChild</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">data</SPAN> <SPAN style="COLOR: #0000cc">+</SPAN> <SPAN style="COLOR: #ff00ff">"("</SPAN> <SPAN style="COLOR: #0000cc">+</SPAN> empid<SPAN style="COLOR: #0000cc">[</SPAN>0<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">firstChild</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">data</SPAN> <SPAN style="COLOR: #0000cc">+</SPAN> <SPAN style="COLOR: #ff00ff">")"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;row <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff0000">document</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">createElement</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"tr"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cell <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff0000">document</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">createElement</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"td"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;row<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">style</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">cursor</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">"pointer"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #ff9900">//fuck css<BR></LI>
<LI></SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cell<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">className</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">"mytd"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cell<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">onmouseout</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">{</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">className</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">'mouseOver'</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><SPAN style="COLOR: #0000cc">}</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cell<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">onmouseover</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">{</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">className</SPAN><SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">'mouseOut'</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><SPAN style="COLOR: #0000cc">}</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cell<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">setAttribute</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"bgcolor"</SPAN><SPAN style="COLOR: #0000cc">,</SPAN> <SPAN style="COLOR: #ff00ff">"#FFFAFA"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cell<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">setAttribute</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"border"</SPAN><SPAN style="COLOR: #0000cc">,</SPAN> <SPAN style="COLOR: #ff00ff">"0"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cell<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">onclick</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">{</SPAN> populateName<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #0000cc">,</SPAN> inputfield<SPAN style="COLOR: #0000cc">,</SPAN> otherfield<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #0000cc">}</SPAN> <SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txtNode <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff0000">document</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">createTextNode</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>nextNode<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cell<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">appendChild</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>txtNode<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;row<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">appendChild</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>cell<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nameTableBody<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">appendChild</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>row<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">function</SPAN> calculateOffsetLeft<SPAN style="COLOR: #0000cc">(</SPAN>field<SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">{</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">return</SPAN> calculateOffset<SPAN style="COLOR: #0000cc">(</SPAN>field<SPAN style="COLOR: #0000cc">,</SPAN> <SPAN style="COLOR: #ff00ff">"offsetLeft"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN> <BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">function</SPAN> calculateOffsetTop<SPAN style="COLOR: #0000cc">(</SPAN>field<SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">{</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">return</SPAN> calculateOffset<SPAN style="COLOR: #0000cc">(</SPAN>field<SPAN style="COLOR: #0000cc">,</SPAN> <SPAN style="COLOR: #ff00ff">"offsetTop"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN> <BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">function</SPAN> calculateOffset<SPAN style="COLOR: #0000cc">(</SPAN>field<SPAN style="COLOR: #0000cc">,</SPAN> attr<SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">{</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">var</SPAN> offset <SPAN style="COLOR: #0000cc">=</SPAN> 0<SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>field<SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">{</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;offset <SPAN style="COLOR: #0000cc">+</SPAN><SPAN style="COLOR: #0000cc">=</SPAN> field<SPAN style="COLOR: #0000cc">[</SPAN>attr<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;field <SPAN style="COLOR: #0000cc">=</SPAN> field<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">offsetParent</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">return</SPAN> offset<SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">function</SPAN> populateName<SPAN style="COLOR: #0000cc">(</SPAN>cell<SPAN style="COLOR: #0000cc">,</SPAN> inputfield<SPAN style="COLOR: #0000cc">,</SPAN> otherfield<SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">var</SPAN> selectedvalue <SPAN style="COLOR: #0000cc">=</SPAN> cell<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">firstChild</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">nodeValue</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>inputfield<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">id</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">"ajaxwon"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;otherfield<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">value</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> selectedvalue<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">substring</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>0<SPAN style="COLOR: #0000cc">,</SPAN> selectedvalue<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">length</SPAN> <SPAN style="COLOR: #0000cc">-</SPAN> 9<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputfield<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">value</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> selectedvalue<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">substring</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>selectedvalue<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">length</SPAN> <SPAN style="COLOR: #0000cc">-</SPAN> 8<SPAN style="COLOR: #0000cc">,</SPAN> selectedvalue<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">length</SPAN> <SPAN style="COLOR: #0000cc">-</SPAN>1<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><SPAN style="COLOR: #0000ff">else</SPAN><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputfield<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">value</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> selectedvalue<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">substring</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>0<SPAN style="COLOR: #0000cc">,</SPAN> selectedvalue<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">length</SPAN> <SPAN style="COLOR: #0000cc">-</SPAN> 8<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;otherfield<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">value</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> selectedvalue<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">substring</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>selectedvalue<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">length</SPAN> <SPAN style="COLOR: #0000cc">-</SPAN> 7<SPAN style="COLOR: #0000cc">,</SPAN> selectedvalue<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">length</SPAN> <SPAN style="COLOR: #0000cc">-</SPAN>1<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clearNames<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN> <BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">function</SPAN> clearNames<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">{</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">var</SPAN> ind <SPAN style="COLOR: #0000cc">=</SPAN> nameTableBody<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">childNodes</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">length</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">for</SPAN> <SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000ff">var</SPAN> i <SPAN style="COLOR: #0000cc">=</SPAN> ind <SPAN style="COLOR: #0000cc">-</SPAN> 1<SPAN style="COLOR: #0000cc">;</SPAN> i <SPAN style="COLOR: #0000cc">&gt;</SPAN><SPAN style="COLOR: #0000cc">=</SPAN> 0 <SPAN style="COLOR: #0000cc">;</SPAN> i<SPAN style="COLOR: #0000cc">-</SPAN><SPAN style="COLOR: #0000cc">-</SPAN><SPAN style="COLOR: #0000cc">)</SPAN> <SPAN style="COLOR: #0000cc">{</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nameTableBody<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">removeChild</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>nameTableBody<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">childNodes</SPAN><SPAN style="COLOR: #0000cc">[</SPAN>i<SPAN style="COLOR: #0000cc">]</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #0000cc">}</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;popupdiv<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">style</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">display</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">"none"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN></SPAN></LI></OL></DIV></DIV>
<DIV>&nbsp;</DIV>
<DIV>
<DIV id=codeText class=codeText>
<OL style="PADDING-BOTTOM: 5px; MARGIN: 0px 1px 0px 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 5px" class=dp-css>
<LI><SPAN style="COLOR: #000000"><SPAN style="COLOR: #0000ff">function</SPAN> rrsendRequest<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputfield <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff0000">document</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">getElementById</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"ajaxempName"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;otherfield <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff0000">document</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">getElementById</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"empNo"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myinitialization<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>inputfield<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">value</SPAN><SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">length</SPAN> <SPAN style="COLOR: #0000cc">&gt;</SPAN> 0<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xmlHttp <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #0000ff">new</SPAN> XMLHttpRequest<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xmlHttp<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">onreadystatechange</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> handleStateChange<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000ff">var</SPAN> queryString <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">"&lt;%=base %&gt;/AjaxSearchAction.do?inputname="</SPAN> <SPAN style="COLOR: #0000cc">+</SPAN> <SPAN style="COLOR: #0000ff">escape</SPAN><SPAN style="COLOR: #0000cc">(</SPAN>inputfield<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">value</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xmlHttp<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">open</SPAN><SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"POST"</SPAN><SPAN style="COLOR: #0000cc">,</SPAN> queryString<SPAN style="COLOR: #0000cc">,</SPAN> <SPAN style="COLOR: #0000ff">true</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xmlHttp<SPAN style="COLOR: #0000cc">.</SPAN>send<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><SPAN style="COLOR: #0000ff">else</SPAN><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clearNames<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: #0000cc">}</SPAN></SPAN></LI></OL></DIV></DIV>
页: [1]
查看完整版本: 自己实现的auto complete