asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0
table border="1" align="center">
 <tr>
  <td align="center" colspan="3">双击输入框看看:</td>
 </tr>
 <tr align="center">
  <td>数量</td>
  <td>产地</td>
  <td>生产日期</td>
 </tr>
 <tr>
  <td><input type="text" name="aa" ondblclick="changeCells(this)" /></td>
  <td><input type="text" name="bb" value="233" ondblclick="changeCells(this)" /><input type="text" name="cc" ondblclick="changeCells(this)" /></td>
  <td><input type="text" name="dd" ondblclick="changeCells(this)" /></td>
 </tr>
 <tr>
  <td><input type="text" name="aa" ondblclick="changeCells(this)" /></td>
  <td><input type="text" name="bb" ondblclick="changeCells(this)" /><input type="text" name="cc" ondblclick="changeCells(this)" /></td>
  <td><input type="text" name="dd" ondblclick="changeCells(this)" /></td>
 </tr>
 <tr>
  <td><input type="text" name="aa" ondblclick="changeCells(this)" /></td>
  <td><input type="text" name="bb" ondblclick="changeCells(this)" /><input type="text" name="cc" ondblclick="changeCells(this)" /></td>
  <td><input type="text" name="dd" ondblclick="changeCells(this)" /></td>
 </tr>
 
</table>
<script>
function changeCells(inp){
 if(confirm("批量修改下面的数据吗?")){
  var table,trs,tr,tds,td;
  td = inp.parentElement;
  tr = td.parentElement;
  table = tr.parentElement;
  trs = table.getElementsByTagName("tr");
  for(var i=tr.rowIndex;i<trs.length;i++ ){
   tds = trs[i].getElementsByTagName("td");
   var tdinps = tds[td.cellIndex].getElementsByTagName("input");
   for(var k in tdinps){
    if(tdinps[k].name == inp.name){
     tdinps[k].value = inp.value;
    }
   }
  }
 }
}
</script>
posted on 2006-04-03 14:44 汪杰 阅读(203) 评论(0)  编辑 收藏 引用 所属分类: hengxing网站js
只有注册用户登录后才能发表评论。

<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 459293
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜