html:multibox 全选的方法,multibox全选与全不选功能的实现,复选框全选

<script language="javascript" type="text/javascript">
function checkAll(e, itemName)
{
   var aa = document.getElementsByName(itemName);
   for (var i=0; i<aa.length; i++)
    aa[i].checked = e.checked;
}
function checkItem(e, allName)
{
   var all = document.getElementsByName(allName)[0];
   if(!e.checked) all.checked = false;
   else
   {
     var aa = document.getElementsByName(e.name);
     for (var i=0; i<aa.length; i++)
      if(!aa[i].checked) return;
     all.checked = true;
   }
}

</script>

<input type=checkbox name=mmAll onclick="checkAll(this, 'kk_BlacklistVehicle_UserManage_BMQX_CheckBox')">

<input type=checkbox name=YHD onclick="checkAll(this, 'kk_BlacklistVehicle_UserManage_BMQX_SC_CheckBox')">
    已获得权限部门

<html:multibox property="kk_BlacklistVehicle_UserManage_BMQX_CheckBox"  onclick="checkItem(this, 'mmAll')">
       <bean:write name="element" property="bm" />
      </html:multibox>

<html:multibox property="kk_BlacklistVehicle_UserManage_BMQX_SC_CheckBox" onclick="checkItem(this, 'YHD')">
       <bean:write name="element" property="idbmqx" />
      </html:multibox>

 这样就实现了一个jsp里多个multibox 的全选了

multibox 的property与input里onclick="checkAll(this, 'kk_BlacklistVehicle_UserManage_BMQX_CheckBox')"中的第2个参数对应

multibox 里onclick="checkItem(this, 'mmAll')"中第2个参数与input中的name相对应

 

黑色头发  http://heisetoufa.iteye.com

如果发现本文有误,欢迎批评指正

你可能感兴趣的:(JavaScript,html,bean,jsp)