我有一个 aspx 页面,其中有三个占位符。现在我在每个占位符内都有复选框。如何检索客户端复选框的选中属性。我尝试了以下代码,但它不起作用。
<asp:CheckBox ID="lblIsActive" runat="server" CssClass="s_label" />
function Mark_Confirm(elem)
{
//var chk=document.getElementById("<%=lblIsActive.ClientID%>");
var div = document.getElementById('<% = lblIsActive.ClientID %>');
var chk = div.getElementsByTagName('input');
var len = chk.length;
if (chk.type == 'checkbox')
chk.checked = elem.checked;
if(chk.checked==true)
{
if (confirm("Do you want to mark the device as lost?"))
{
var confirm_value1 = document.createElement("INPUT");
confirm_value1.type = "hidden";
confirm_value1.name = "confirm_value1";
confirm_value1.value = "Yes";
}
else
{
confirm_value1.value = "No";
}
}
if(chk.checked==false)
{
if (confirm("Do you want to mark the device as active?"))
{
var confirm_value2 = document.createElement("INPUT");
confirm_value2.type = "hidden";
confirm_value2.name = "confirm_value2";
confirm_value2.value = "Yes";
}
else
{
confirm_value2.value = "No";
}
}
document.forms[0].appendChild(confirm_value1);
document.forms[0].appendChild(confirm_value2);
}