Monday, 9 September 2013

Get the value of items in checkboxlist and save in hiddenfield

Get the value of items in checkboxlist and save in hiddenfield

I have a checkboxlist.
<asp:CheckBoxList ID="cblList" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="S04">1</asp:ListItem>
<asp:ListItem Value="S08">2</asp:ListItem>
<asp:ListItem Value="S09">3</asp:ListItem>
<asp:ListItem>All</asp:ListItem>
</asp:CheckBoxList>
Generated HTML
1
2
3
4
and hidden field
<asp:HiddenField ID="hddnValue" runat="server" />
I want to store the selected value of checkboxlist in HiddenField.
I tried
$(function() {
$('#ctl00_ContentPlaceHolder1_btnConfirm').click(function() {
debugger;
var val = [];
$(':checkbox:checked').each(function(i) {
val[i] = $(this).val();
});
});
});
without any luck. Please Help.
Thank you,
Rahul

No comments:

Post a Comment