I am trying to get the values from checkboxlist in jquery and depending from which value there is, make the checkbox checked or unchecked. This is what I have:
<asp:CheckBoxList CssClass="styled" ID="chkTestTypeEdit" RepeatDirection="Horizontal" style="padding:5px;" runat="server"> <asp:ListItem Value="1" Text="Y/N" /> <asp:ListItem Value="2" Text="Num" /> </asp:CheckBoxList>
Then before modal popup is open I have this piece of code:
$(document).on("click", ".open-EditTest", function () {
var optesttype =$(this).data('optesttype');
var items = $('#<% = chkTestTypeEdit.ClientID %> input:checkbox');
for (var i = 0; i < items.length; i++) {
var val = $('#ctl00_MainContent_chkTestTypeEdit_0').val();
var val2 = $('label[for=" + <%= chkTestTypeEdit.ClientID %> +_0 "]').text();
if (items[i].value == optesttype) {
items[i].checked = true;
break;
}
}
$('#EditTest').modal('show');
});
So the optesttype will have either 1 or 2, and then I am trying to compare that agains the item[i] value but that value is always 'on'. I tried two methods I found on the net with var val and val2, but nothing gets selected. How do you guys think I need to approach this? Thanks, Laziale