我在頁面上有一個「全選」複選框,它將取消選擇並選擇下面的複選框。複選框在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;'正在爲我工作,請建議,如果有人取消選擇兒童複選框,那麼它應該取消選擇主和 –