javascriptの表に対する操作

4524 ワード

<HTML> 
<head> 
<script   language="javascript"> 
var   curRow=null; 
function   SelectRow(TrObj){ 
if(curRow)   curRow.style.backgroundColor="#FFFFFF"; 
TrObj.style.backgroundColor="#FFCC00"; 
curRow=TrObj; 
} 
function   CalTotalScore(){ 
   
} 
function   ToModify(){ 
var   pWin=window.open("","","width=200px,height=150px,left="+(screen.width-200)/2+",top="+(screen.height-150)/2); 
pWin.document.write(divOpen.innerHTML); 
pWin.document.all.txtMath.value=curRow.cells[1].innerText; 
pWin.document.all.txtHis.value=curRow.cells[2].innerText; 
pWin.document.all.txtEng.value=curRow.cells[3].innerText; 
   
} 
</script> 
</head> 
   
<body   onLoad="CalTotalScore();"> 
<table   align="center"   width="500"   border="1"   cellpadding="0"   cellspacing="0"   style="border-collapse:collapse   "   bordercolor="#111111"> 
      <tr> 
          <td   width="100"   align="center">  </td> 
          <td   width="100"   align="center">  </td> 
          <td   width="100"   align="center">  </td> 
          <td   width="100"   align="center">  </td> 
          <td   width="100"   align="center">  </td> 
      </tr> 
      <tr   onClick="SelectRow(this)"> 
          <td   align="center">  </td> 
          <td   align="right">78</td> 
          <td   align="right">92</td> 
          <td   align="right">85</td> 
          <td   align="right">&nbsp;</td> 
      </tr> 
      <tr   onClick="SelectRow(this)"> 
          <td   align="center">  </td> 
          <td   align="right">82</td> 
          <td   align="right">68</td> 
          <td   align="right">91</td> 
          <td   align="right">&nbsp;</td> 
      </tr> 
      <tr> 
          <td   align="center"   colspan="5"> 
<input   type="button"   value="  "   onClick="ToModify()">&nbsp; 
<input   type="button"   value="  "   onClick="javascript:window.close();"> 
</td> 
      </tr> 
</table> 
<div   id="divOpen"   style="display:none   "> 
<script   language="javascript"> 
function   doSave(){ 
var   opener=window.opener; 
opener.curRow.cells[1].innerText=txtMath.value; 
opener.curRow.cells[2].innerText=txtHis.value; 
opener.curRow.cells[3].innerText=txtEng.value; 
} 
</script> 
<table   width="80%"   align="center"   border="1"   cellpadding="0"   cellspacing="0"   style="border-collapse:collapse   "   bordercolor="#111111"> 
      <tr> 
          <td   width="40%"   align="right">  ;&nbsp;</td> 
          <td   width="60%"><input   type="text"   id="txtMath"   style="width:100%   "></td> 
      </tr> 
      <tr> 
          <td   align="right">  ;&nbsp;</td> 
          <td><input   type="text"   id="txtHis"   style="width:100%   "></td> 
      </tr> 
      <tr> 
          <td   align="right">  ;&nbsp;</td> 
          <td><input   type="text"   id="txtEng"   style="width:100%   "></td> 
      </tr> 
      <tr> 
          <td   colspan="2"   align="center"><input   type="button"   value="  "   onClick="doSave()"></td> 
      </tr> 
</table> 
</div> 
</body> 
   
</html>