If I have the following CheckBoxList
<asp:CheckBoxList ID="typeCheckBoxList" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="0">Student</asp:ListItem>
<asp:ListItem Value="1">Parent</asp:ListItem>
<asp:ListItem Value="2">Educational</asp:ListItem>
<asp:ListItem Value="3">Specialist </asp:ListItem>
<asp:ListItem Value="5">Other</asp:ListItem>
</asp:CheckBoxList>
Using Jquery i want to get the values of the selected items, I use the following code
$('#<%= typeCheckBoxList.ClientID %> input:checked').each(function() {
alert($(this).val());
alert($(this).next('label').text());
});
$(this).val()
always returns "on
" and I can't return values such as 0 ,1
, etc.
Is there any way to do that ?
EDIT : Rendered Markup:
<table id="RegisterationWUC1_typeCheckBoxList" class="listVertical" border="0">
<tr>
<td>
<input id="RegisterationWUC1_typeCheckBoxList_0" type="checkbox" name="RegisterationWUC1$typeCheckBoxList$0" />
<label for="RegisterationWUC1_typeCheckBoxList_0">Student</label>
</td>
<td>
<input id="RegisterationWUC1_typeCheckBoxList_1" type="checkbox" name="RegisterationWUC1$typeCheckBoxList$1" />
<label for="RegisterationWUC1_typeCheckBoxList_1">Parent</label>
</td>
<td>
<input id="RegisterationWUC1_typeCheckBoxList_2" type="checkbox" name="RegisterationWUC1$typeCheckBoxList$2" />
<label for="RegisterationWUC1_typeCheckBoxList_2">Educational</label>
</td>
<td>
<input id="RegisterationWUC1_typeCheckBoxList_3" type="checkbox" name="RegisterationWUC1$typeCheckBoxList$3" />
<label for="RegisterationWUC1_typeCheckBoxList_3">Specialist </label>
</td>
<td>
<input id="RegisterationWUC1_typeCheckBoxList_4" type="checkbox" name="RegisterationWUC1$typeCheckBoxList$4" />
<label for="RegisterationWUC1_typeCheckBoxList_4">other</label>
</td>
</tr>
</table>