我在页面上有一个“全选”复选框,它将取消选择并选择下面的复选框。复选框在javascript中选择和取消选择功能
<div class="field">
<div class="SelectAllCheckBox">
<input type="checkbox" id="SelectAllCheckBox" />
<label for="SelectAllCheckBox">Select All</label>
</div>
</div>
<div id="TargetsPanel" class="panel" style="display: block;">
<div class="body stack-calc">
<table id="TargetsTable" class="tm-list" cellspacing="0">
<colgroup>
<col width="20px">
<col width="20%">
<col>
</colgroup>
<thead>
<tr>
<th></th>
<th> Language </th>
<th> Workflow </th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>
<span class="LanguageName">Arabic</span>
<ul class="Publications">
<li>
<img alt="" src="/test/tt.png">
<input type="checkbox" id="tcm:0-235-1" name="tcm:0-235-1" checked="checked">
<label for="tcm:0-235-1">Test Arabic</label>
</li>
</ul>
</td>
<td><select name="_1041" disabled=""><option value="1650">Test</option></select></td>
</tr>
<tr>
<td></td>
<td>
<span class="LanguageName">Test Chinese (HongKong)</span>
<ul class="Publications">
<li>
<img alt="" src="/test/mm.png">
<input type="checkbox" id="tcm:0-368-1" name="tcm:0-368-1" checked="checked">
<label for="tcm:0-368-1">Test (Traditional Chinese)</label>
</li>
</ul>
</td>
<td><select name="_1116" disabled=""><option value="1650">Test2</option></select></td>
</tr>
...
...
...//It goes on for other checkboxes.
...
...
</tbody>
</table>
</div>
</div>
现在我想选择和取消选择“SelectAllCheckBox”复选框下方所有复选框的功能。在复选框中没有任何常见操作,除了它们是复选框,并且我希望这些复选框只有其他才会出界。
<input type="checkbox" id="tcm:0-235-1" name="tcm:0-235-1" checked="checked">
<input type="checkbox" id="tcm:0-368-1" name="tcm:0-368-1" checked="checked">
....
....
....
感谢
编辑:
c.SelectAllCheckBox = $("#SelectAllCheckBox"); //I am initializing the existing checkbox id
$evt.addEventHandler(c.SelectAllCheckBox, "click", this.getDelegate(this._onSelectAllCheckBoxClick)); //Here I am adding the event listner
TranslationJob.prototype._onSelectAllCheckBoxClick = function TranslationJob$_onSelectAllCheckBoxClick(headDoc, items)
{
var p = this.properties;
var c = p.controls;
//Here I want code which will deselect and select the checkboxes
};
要求:
功能应该工作在主选择所有子作为应选择,一旦主人是取消所有的孩子应该是取消选择,如果任何儿童复选框被取消选择,那么主人应该被取消选择,如果所有的孩子被选中,主人应该被选中automati凯莉
好的,谢谢Relfor,如果有人取消选择复选框,那么它应该取消选择主“全选”复选框,并在“this.checked”上给出错误。说TypeError:this.checked是未定义的 –
我增加了功能。当你运行小提琴时,或者当你尝试在你的项目中嵌入代码时,它是否给你错误? –
Relfor,你知道我已经指出,'this.checked;'正在为我工作,请建议,如果有人取消选择儿童复选框,那么它应该取消选择主和 –