嗨我正在使用此代码获取值,但它只显示文本而不是值,请帮助我... 我的复选框列表是:
<asp:CheckBoxList ID="CheckBoxList1" runat="server" onchange=" GetSelectedItem();">
<asp:ListItem Text ="Show only Refundable Fares" Value ="false" ></asp:ListItem>
<asp:ListItem Text ="helloe" Value ="true" ></asp:ListItem>
<asp:ListItem Text ="" Value ="" ></asp:ListItem>
</asp:CheckBoxList>
我的javascript代码是:
<script type = "text/javascript">
function GetSelectedItem() {
var CHK = document.getElementById("<%=CheckBoxList1.ClientID%>");
// var CHK = document.getElementById("CheckBoxList1").;
var checkbox = CHK.getElementsByTagName("input");
var label = CHK.getElementsByTagName("label");
var refund = new Array();
var values = "";
for (var i = 0; i < checkbox.length; i++) {
if (checkbox[i].checked) {
refund[i] = label[i].innerText;
alert("Selected = " + refund);
}
}
$('#hdnrefund').val(refund);
return false;
}
</script>
答案 0 :(得分:0)
更改
label[i].innerText;
到
label[i].value;