读书人

Javascript访问,ASP.NET控件中Table控

发布时间: 2011-12-30 23:30:45 作者: rapoo

Javascript访问,ASP.NET控件中Table控件的TableCell如何实现!!在线等~!请大家帮助一下!
小弟有一个程序需要使用Javascript来访问ASP.NET中Table控件的TableCell单元并对它其中的文本进行更改,但这个TableCell单元是不定的需要由单击时的一个变量来决定,以下在小弟尝试时写的代码不过没有实现想要的效果,请各位帮帮忙!
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>

<script type= "text/javascript ">

function inputtable(row)
{
alert(row);
// k = document.getElementById[ "cel1 "].id;
// document.all.k.innertext = "45 ";
return false;

}

function doc()
{
var row;
row = "cel1 ";
inputtable(row);
alert( "end! ");
}

</script>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:Table ID= "Table1 " runat= "server ">
<asp:TableRow runat= "server " ID= "row1 ">
<asp:TableCell runat= "server " ID= "cel1 " > 123 </asp:TableCell>
<asp:TableCell runat= "server " ID= "cel2 "> </asp:TableCell>
</asp:TableRow>
<asp:TableRow runat= "server ">
<asp:TableCell runat= "server " ID= "cel3 "> </asp:TableCell>
<asp:TableCell runat= "server " ID= "cel4 "> </asp:TableCell>
</asp:TableRow>


</asp:Table>
    <asp:TextBox ID= "T1 " runat= "server "> </asp:TextBox> <br />
  <input id= "Button1 " type= "button " value= "button " onclick= "doc() " /> </div>
</form>
</body>
</html>

简单说就是页面存在一个Table控件,这个控件中有四个TableCell单元格,现在想通过调用Javascript的inputtable函数给其中由row变量所存的对应的那个单元格的ID进行改变它的文本。
比如:
我要对cel2单元格进行赋值,我只要给row赋 "cel2 "然后通过inputtable来改变这个单元格中的内容!我要怎么做!

[解决办法]
function inputtable(row) { row.innerHTML = "232232131 "; return false; } function doc() { var row; row = document.getElementById( "cel1 "); inputtable(row); alert( "end! "); }

读书人网 >asp.net

热点推荐