<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="javascript">

window.onload=function(){
  if(typeof(window.document.all.mytable)=="undefined"){
   return;
  }
  var trLen=window.document.all.mytable.children[1].children.length;  
  for(i=0;i < trLen;i++){
   window.document.all.mytable.children[1].children[i].attachEvent('onclick',showInfo);
  }
  window.document.all.mytable.children[1].children[0].children[0].fireEvent("onclick");
}

 


function showInfo(){

  var oTr=window.event.srcElement.parentElement;
  if(oTr.tagName != "TR") {
   return;
  }
  show(oTr); 

 }
 function show(record){  
  window.document.all.NAME.value    =record.children[0].innerHTML;
  window.document.all.PASSWORD.value=record.children[1].innerText;
  window.document.all.LOCATION.value=record.children[2].innerText; 
 
 }
</script>
</head>

<body>
<form name="theForm" method="get">
 NAME:&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="NAME"><br>
 PASSWORD:<input type="text" name="PASSWORD"><br>
 LOCATION:<input type="text" name="LOCATION"><br>
 <button onClick="test()" >测试</button>
</form>

<table id="mytable">
 <thead>
  <tr><th>NAME</TH><th>PASSWORD</TH><th>LOCATION</TH></tr>
 </thead>
 <tbody>
   <tr><td>JING</td><td>11111</td><td>SHHAI  </td></tr>
  <tr><td>LI  </td><td>22222</td><td>BEIJING</td></tr>
  <tr><td>WU  </td><td>33333</td><td>HAINANG</td></tr>
 </tbody>
</table>

</body>
</html>