首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

怎么显示表格内容

2012-03-11 
如何显示表格内容我有一个table表格,选中某一行后,点击“查看(button)”按钮可以实现对该行内容的显示?如何

如何显示表格内容
我有一个table表格,选中某一行后,点击“查看(button)”按钮可以实现对该行内容的显示?如何用JS实现?
请教下高手:)
谢谢!

[解决办法]

HTML code
<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>newpage</title></head><body><table border="1" width="100%"> <tr>  <td><input type=checkbox></td > <td>11111</td  >  </tr>  <td><input type=checkbox></td> <td>22222</td></tr> <td><input type=checkbox></td> <td>33333</td> </tr> <td><input type=checkbox></td> <td>44444</td> </tr> <td><input type=checkbox></td> <td>55555</td>   </tr>  </table><input type=button value="查看" onclick=getVal()></body><script>function getVal(){var t=document.getElementsByTagName("table")[0];for(var i=0;i<t.rows.length;i++){if(t.rows(i).cells(0).firstChild.checked){alert("第"+(i+1)+"行已选中,值为:"+t.rows(i).cells(1).innerText);}}}</script></html>
[解决办法]
JScript code
window.onload=function(){   var buttons=document.getElementsByTagName("input");   for(var i=0;i<buttons.length;i++)   {      var thisButton=buttons[i];      if(thisButton.getAttribute("value")=="view")      {         thisButton.onclick=function()         {            $("divDisplay").innerHTML=this.parentNode.parentNode.innerHTML;         }      }   }}function $(objID){   return document.getElementById(objID);} 

热点排行
Bad Request.