我想在选中一个复选框时显示/隐藏一个 div。它目前适用于“全选”,但我无法让它与单个复选框一起使用。这是“全选”的代码:
JS:
<script language='JavaScript'>
var checkboxcount = 1;
function doCheckOne() {
if(checkboxcount == 0) {
with (document.messageform) {
for (var i=0; i < elements.length; i++) {
if (elements[i].type == 'checkbox') {
elements[i].checked = false;
document.getElementById('mail_delete_button').style.display = "none";
}
}
checkboxcount = checkboxcount + 1;
}
} else
with (document.messageform) {
for (var i=0; i < elements.length; i++) {
if (elements[i].type == 'checkbox') {
elements[i].checked = true;
document.getElementById('mail_delete_button').style.display = "block";
}
}
checkboxcount = checkboxcount - 1;
}
}
</script>
HTML:
<a href="javascript:void(0);" onclick="doCheckAll();this.blur();">Select all</a>
<div id="mail_delete_button" style="display: none;"></div>
我想在选中单个复选框时显示 div“mail_delete_button”,并在没有选中任何内容时隐藏它。注意:我的 html/input 字段采用“messageform”形式这是我的输入代码:
<input type='checkbox' name='delete_convos[]' value='{$pms[pm_loop].pmconvo_id}'>
任何帮助将不胜感激!谢谢!:)