利用js的Node遍历找到repeater的一个字段实例介绍
人气:0
js部分:
var checkboxs = document.getElementsByTagName("input");
for(var i=0;i<checkboxs.length;i++)
{
if(checkboxs[i].type=="checkbox" && checkboxs[i].checked==true){
var trobj=checkboxs[i].parentNode.parentNode; //找到tr节点
if(trobj.rowIndex > 0){
var tdobj=trobj.children;
var amount = tdobj[3].children.item(0).value; //找到td节点的value 对应第4个td
alert(amount);
}
}
}
html的repeater
<asp:repeater id="repeater1" runat="server">
<ItemTemplate>
<tr class="TableDetail2">
<TD>
<input type =checkbox name="checkboxs" ID="checkbox" Runat="server" Width="15" value = '<%# Container.DataItem("mocode") %>'/>
</TD>
<td class="nowrap">
<asp:ImageButton id="btnkxcode" runat="server" Width="15" ImageUrl="../image/search.jpg" CommandName="btnkx"
Height="15"></asp:ImageButton>
<asp:TextBox id="ckxcode" runat="server" CssClass="TextBox1" Text='<%# Container.DataItem("itemtype") %>'>
</asp:TextBox></td>
<td class="nowrap">
<asp:ImageButton id="btnkxname" runat="server" Width="15" ImageUrl="../image/search.jpg" CommandName="btnkxn"
Height="15"></asp:ImageButton>
<asp:TextBox id="ckxname" runat="server" CssClass="TextBox1" Text='<%# Container.DataItem("itemname") %>'>
</asp:TextBox>
</td>
<td class="nowrap">
<asp:TextBox id="amount" runat="server" CssClass="TextBox1" Text='<%# Container.DataItem("ysamount") %>'>
</asp:TextBox></td>
</tr>
</ItemTemplate>
</asp:repeater>
复制代码 代码如下:
var checkboxs = document.getElementsByTagName("input");
for(var i=0;i<checkboxs.length;i++)
{
if(checkboxs[i].type=="checkbox" && checkboxs[i].checked==true){
var trobj=checkboxs[i].parentNode.parentNode; //找到tr节点
if(trobj.rowIndex > 0){
var tdobj=trobj.children;
var amount = tdobj[3].children.item(0).value; //找到td节点的value 对应第4个td
alert(amount);
}
}
}
html的repeater
复制代码 代码如下:
<asp:repeater id="repeater1" runat="server">
<ItemTemplate>
<tr class="TableDetail2">
<TD>
<input type =checkbox name="checkboxs" ID="checkbox" Runat="server" Width="15" value = '<%# Container.DataItem("mocode") %>'/>
</TD>
<td class="nowrap">
<asp:ImageButton id="btnkxcode" runat="server" Width="15" ImageUrl="../image/search.jpg" CommandName="btnkx"
Height="15"></asp:ImageButton>
<asp:TextBox id="ckxcode" runat="server" CssClass="TextBox1" Text='<%# Container.DataItem("itemtype") %>'>
</asp:TextBox></td>
<td class="nowrap">
<asp:ImageButton id="btnkxname" runat="server" Width="15" ImageUrl="../image/search.jpg" CommandName="btnkxn"
Height="15"></asp:ImageButton>
<asp:TextBox id="ckxname" runat="server" CssClass="TextBox1" Text='<%# Container.DataItem("itemname") %>'>
</asp:TextBox>
</td>
<td class="nowrap">
<asp:TextBox id="amount" runat="server" CssClass="TextBox1" Text='<%# Container.DataItem("ysamount") %>'>
</asp:TextBox></td>
</tr>
</ItemTemplate>
</asp:repeater>
加载全部内容