我的.ascx页面中有一个 cblSchedule 复选框列表,允许选择每日/每周:
<div class="form-group" id="schedule">
<label class="control-label col-md-2" id="lblSchedule">Schedule</label>
<div class="col-md-3">
<div class="input-group">
<asp:CheckboxList ID="cblSchedule" ClientIDMode="Static" CssClass="chkLabel" runat="server" AutoPostBack="false" CellPadding="5" CellSpacing="5" RepeatDirection="Horizontal" RepeatLayout="Table" onchange="ToggleSchedule(this)" >
<asp:ListItem Text="Daily" Value="Daily"></asp:ListItem>
<asp:ListItem Text="Weekly" Value="Weekly"></asp:ListItem>
</asp:CheckboxList>
</div>
</div>
</div>
选中每周时,会显示 chkSelectDay 复选框列表:
<div class="form-group" id="divSelectDay" >
<label class="control-label col-md-2" id="lblSelectDay">Select Day of Week</label>
<div class="col-md-3">
<div class="input-group">
<asp:CheckBoxList ID="chkSelectDay" CssClass="chkLabel" ClientIDMode="Static" runat="server" AutoPostBack="false" CellPadding="5" CellSpacing="5" RepeatDirection="Horizontal" RepeatLayout="Table">
<asp:ListItem Value="Monday">Mon</asp:ListItem>
<asp:ListItem Value="Tuesday">Tue</asp:ListItem>
<asp:ListItem Value="Wednesday">Wed</asp:ListItem>
<asp:ListItem Value="Thursday">Thu</asp:ListItem>
<asp:ListItem Value="Friday">Fri</asp:ListItem>
<asp:ListItem Value="Saturday">Sat</asp:ListItem>
<asp:ListItem Value="Sunday">Sun</asp:ListItem>
</asp:CheckBoxList>
</div>
</div>
</div>
我有一个切换功能,当在 cblSchedule 中选中/取消选中每周时,会显示/隐藏 chkSelectDay :
function ToggleSchedule(controlId) {
var frmControl = document.getElementById(controlId.id);
var divDay = document.getElementById("divSelectDay");
var checkbox = frmControl.getElementsByTagName("input");
var counter = 0;
for (var i = 0; i < checkbox.length; i++) {
if (checkbox[i].checked)
{
if (checkbox[i].value == "Weekly")
divDay.style.display = 'block';
}
else
{
if (checkbox[i].value == "Weekly") {
divDay.style.display = 'none';
//UNCHECK ALL chkSelectDay checkboxes <--
}
}
}
}
我想添加在 cblSchedule 中未选中每周时取消选中 chkSelectDay 中所有复选框的功能。
我试图通过$('#chkSelectDay')
来检索复选框计数。
但是我无法使用.Count
或.Length
,所以无法使用for-loop
来设置.Checked = false
。
谢谢
答案 0 :(得分:1)
您应该知道的第一件事是,默认情况下,census=pd.Series([2000,4432,5435,43252,63463,423432,3525,54353,6363])
census.index=['AL','AL','AL','AL','AK','AK','AK','AK','AK']
将其值存储在for (int maxNames = 0; maxNames < names.Length; maxNames++)
{
// Also, move your input WITHIN the loop
userInput = Console.ReadLine(); // store the name in userInput
if (userInput == "") // if the entry is null, stop taking names.
{
Console.WriteLine("You entered {0}", names);
Console.ReadKey();
break;
}
else if (userInput == "QUIT") // if the entry is QUIT, stop taking names.
{
Console.WriteLine("You entered {0}", names);
Console.ReadKey();
break;
}
else
// if it isn't null or QUIT, continue populating the array until we hit the max.
{
// since maxNames is now properly starting at 0,
// you don't need your other name counter variable.
// just use maxNames. The loop process will increase it next cycle through
names[maxNames] = userInput;
}
}
中,而不在客户端显示它。您需要在CheckBoxList
内添加ViewState
属性,以使复选框列表值可在客户端使用:
ClientValue
然后,处理ListItem
事件以确保传递了<asp:CheckboxList ID="cblSchedule" ClientIDMode="Static" CssClass="chkLabel" runat="server" AutoPostBack="false" CellPadding="5" CellSpacing="5" RepeatDirection="Horizontal" RepeatLayout="Table" onchange="ToggleSchedule(this)" >
<asp:ListItem Text="Daily" Value="Daily" ClientValue="Daily"></asp:ListItem>
<asp:ListItem Text="Weekly" Value="Weekly" ClientValue="Weekly"></asp:ListItem>
</asp:CheckboxList>
值,否则请取消选中所有change
复选框:
Weekly
相关问题:
Get the Checkboxlist value when unchecked Client-Side
Check uncheck all CheckBoxes on the basis of another CheckBox
ASP.Net CheckBoxList: Check or uncheck all checkboxes client side using jQuery