日期:2014-05-18 浏览次数:20826 次
function selectAll(formName, checkboxName) { var form = document.all.item(formName); var elements = form.elements[checkboxName]; var count = document.getElementsByName(checkboxName).length; if (count == 1) { if (checkedAll) { elements.checked = false; } else { elements.checked = true; } } else { for (var i = 0; i < elements.length; i++) { var e = elements[i]; if (checkedAll) { e.checked = false; } else { e.checked = true; } } } if (checkedAll) { checkedAll = false; } else { checkedAll = true; } } <s:checkbox name="chk" id="chk" theme="simple" onclick="selectAll('moduleForm','cb');"></s:checkbox> <s:iterator ...> <td align="center"> <s:checkbox name="cb" id="cb" fieldValue="%{pk.code}" theme="simple"></s:checkbox> </td> </s:iterator>