如何使用jquery从转发器获取隐藏字段值?
问题描述:
大家好,
在ASP.NET网页中,我正在使用中继器,
in我有hiddendfields和checkBoxes的再见者。
Hi guys,
In ASP.NET webpage i'm using repeater,
in a repater i have hiddendfields and checkBoxes.
<asp:Repeater ID="rptSearchCandidates" runat="server">
<HeaderTemplate>
<table style="width: 100%;" class="table">
<tr>
<th><b>Code</b></th>
<th><b>Center</b></th>
<th>Candidate NameEN</th>
<th>Candidate NameAR</th>
<th>Select</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="font-weight: bold">
<%# Eval("Code") %>
<asp:HiddenField ID="hdnCandidateID" runat="server" Value='<%# Eval("ID") %>' />
</td>
<td style="font-weight: bold">
<%# Eval("Center.NameEN") %>
</td>
<td>
<%# Eval("NameEN") %>
</td>
<td>
<%# Eval("NameAR") %>
</td>
<td>
<asp:CheckBox ID="chkCandidate" runat="server" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater
>
我尝试过的事情:
i想要获取隐藏字段值使用jQuery选中该行的复选框。
任何人都可以帮助我。
谢谢
>
What I have tried:
i want to fetch hiddenfield values where checkbox of that row in selected, using jQuery.
can any one please help me.
Thanks
答
试试这个
try this
function beoreSave()
{
var selectedIds = [];
(' [id * =chkCandidate]')。each( function (i,item){
if (item.checked){
var val =
('[id*="chkCandidate"]').each(function (i,item) { if (item.checked) { var val =
(item).parent() .parent()。find(' [id * =hdnCandidateID]')。val() ;
selectedIds.push(val);
}
});
alert(selectedIds.join(' ,'));
}
(item).parent().parent().find('[id*="hdnCandidateID"]').val(); selectedIds.push(val); } }); alert(selectedIds.join(',')); }