JavaScript 代碼
<script type="text/javascript">
function dosubmit(name, id) {
var names = document.getElementById(id);
if (names.checked == true) {
checkedAll(name)
}
else {
checkedNo(name)
}
}
//全選
function checkedAll(name) {
var names = document.getElementsByName(name);
var len = names.length;
if (len > 0) {
var i = 0;
for (i = 0; i < len; i++)
names[i].checked = true;
}
}
//全不選
function checkedNo(name) {
var names = document.getElementsByName(name);
var len = names.length;
if (len > 0) {
var i = 0;
for (i = 0; i < len; i++)
names[i].checked = false;
}
}
</script>
調(diào)用的時候
<input name="" type="checkbox" value="" id="checkall"
onclick="dosubmit('printseatno', 'checkall')"/>
onclick="dosubmit('子組件的name值(要一樣)','全選框的id')"
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點擊舉報。