js实现复选框全选功能,代码如下所示:
<? include_once("inc/auth.inc.php"); include_once("inc/utility_all.php"); include_once("inc/utility_org.php"); $connstatus = ($connstatus) ? true : false; if(!isset($TYPE)) $TYPE="0"; $ITEMS_IN_PAGE=10; if(!isset($start) || $start=="") $start=0; $HTML_PAGE_TITLE = _("文件管理"); include_once("inc/header.inc.php"); ?> <script> function open_file(FILE_ID) { URL="read_file.php?FILE_ID="+FILE_ID; myleft=(screen.availWidth-500)/2; mytop=150 mywidth=550; myheight=300; window.open(URL,"read_file","height="+myheight+",width="+mywidth+",status=1,toolbar=no,menubar=no,location=no,scrollbars=yes,top="+mytop+",left="+myleft+",resizable=yes"); } function delete_file(FILE_ID,CUR_PAGE) { msg='<?=_("确认要销毁该项文件吗?")?>'; if(window.confirm(msg)) { URL="delete.php?FILE_ID=" + FILE_ID + "&CUR_PAGE=" + CUR_PAGE; window.location=URL; } } function delete_all() { delete_str=""; for(i=0;i<document.getElementsByName("file_select").length;i++) { el=document.getElementsByName("file_select").item(i); if(el.checked) { val=el.value; delete_str+=val + ","; } } if(i==0) { el=document.getElementsByName("file_select"); if(el.checked) { val=el.value; delete_str+=val + ","; } } if(delete_str=="") { alert("<?=_("要销毁文件,请至少选择其中一个。")?>"); document.form1.reset(); return; } msg='<?=_("确认要销毁已选中的文件吗?")?>'; if(window.confirm(msg)) { url="./delete_all.php?DELETE_STR="+ delete_str +"&PAGE_START=<?=$PAGE_START?>"; window.location=url; } } function order_by(field,asc_desc) { window.location="index1.php?CUR_PAGE=<?=$CUR_PAGE?>&TYPE=<?=$TYPE?>&FIELD="+field+"&ASC_DESC="+asc_desc; } function file_troop(type) { document.form1.action="troop.php?CUR_PAGE=<?=$CUR_PAGE?>&FIELD=<?=$FIELD?>&ASC_DESC=<?=$ASC_DESC?>"; document.form1.target='_self'; document.form1.submit(); } function check_all() { for (i=0;i<document.getElementsByName("file_select").length;i++) { if(document.getElementsByName("allbox")[0].checked) document.getElementsByName("file_select").item(i).checked=true; else document.getElementsByName("file_select").item(i).checked=false; } if(i==0) { if(document.getElementsByName("allbox")[0].checked) document.getElementsByName("file_select").checked=true; else document.getElementsByName("file_select").checked=false; } } function change_roll() { delete_str=""; for(i=0;i<document.getElementsByName("file_select").length;i++) { el=document.getElementsByName("file_select").item(i); if(el.checked) { val=el.value; delete_str+=val + ","; } } if(i==0) { el=document.getElementsByName("file_select"); if(el.checked) { val=el.value; delete_str+=val + ","; } } var myselect=document.getElementById("SROLL_ID"); var index=myselect.selectedIndex ; if(delete_str=="") { alert("<?=_("要组卷文件,请至少选择其中一个。")?>"); document.form1.reset(); return; } roll_id=myselect.options[index].value; url="./change_roll.php?DELETE_STR="+ delete_str +"&ROLL_ID="+roll_id+"&PAGE_START=<?=$PAGE_START?>"; location=url; } function check_one(el) { if(!el.checked) document.getElementsByName("allbox")[0].checked=false; } function shenpi_all() { delete_str=""; for(i=0;i<document.getElementsByName("file_select").length;i++) { el=document.getElementsByName("file_select").item(i); if(el.checked) { val=el.value; delete_str+=val + ","; } } if(i==0) { el=document.getElementsByName("file_select"); if(el.checked) { val=el.value; delete_str+=val + ","; } } if(delete_str=="") { alert("<?=_("要审批文件,请至少选择其中一个。")?>"); document.form1.reset(); return; } msg='<?=_("确认要审批通过已选中的文件吗?")?>'; if(window.confirm(msg)) { // alert(delete_str); url="./shenpi_all.php?SHENPI_STR="+ delete_str +"&start=<?=$start?>"; window.location=url; } } </script> <body> <? // $query = "SELECT count(*) from RMS_FILE_NEW,RMS_ROLL,RMS_ROLL_ROOM where RMS_FILE_NEW.ROLL_ID=RMS_ROLL.ROLL_ID and RMS_ROLL.ROOM_ID=RMS_ROLL_ROOM.ROOM_ID and RMS_FILE_NEW.shenpiren='".$_SESSION["LOGIN_USER_ID"]."' and RMS_FILE_NEW.DEL_USER='' and SHENPISTATUS='1'"; $query = "SELECT count(*) from RMS_FILE_NEW where RMS_FILE_NEW.shenpiren='".$_SESSION["LOGIN_USER_ID"]."' and RMS_FILE_NEW.DEL_USER='' and SHENPISTATUS='1'"; //echo $query."<br>"; if($TYPE!="0") $query .= " and CATALOG_NO='$TYPE' "; //echo $query."<br>"; $cursor= exequery(TD::conn(),$query, $connstatus); $RMS_FILE_NEW_COUNT=0; if($ROW=mysql_fetch_array($cursor)) $RMS_FILE_NEW_COUNT=$ROW[0]; if($RMS_FILE_NEW_COUNT==0) { ?> <table cellspacing="0" cellpadding="3"> <tr> <td><img src="<?=MYOA_STATIC_SERVER?>/static/images/notify_open.gif"><span> <?=_("待审批文件")?></span> </td> </tr> </table> <br> <? Message("",_("无需要审批的文件")); exit; } ?> <table cellspacing="0" cellpadding="3"> <tr> <td><img src="<?=MYOA_STATIC_SERVER?>/static/images/notify_open.gif"><span> <?=_("待审批文件管理")?></span> </td> <td valign="bottom"><?=sprintf(_("共%s条"), '<span> '.$RMS_FILE_NEW_COUNT.'</span>')?> </td> <td valign="bottom"> <?=page_bar($start,$RMS_FILE_NEW_COUNT,$ITEMS_IN_PAGE)?> </td> </tr> </table> <? if($ASC_DESC=="") $ASC_DESC="1"; //if($FIELD=="") // $FIELD="FILE_CODE"; //============================ 显示已发布文件 ======================================= //$query = "SELECT * from RMS_FILE_NEW,RMS_ROLL,RMS_ROLL_ROOM where RMS_FILE_NEW.ROLL_ID=RMS_ROLL.ROLL_ID and RMS_ROLL.ROOM_ID=RMS_ROLL_ROOM.ROOM_ID and RMS_FILE_NEW.shenpiren='".$_SESSION["LOGIN_USER_ID"]."' and RMS_FILE_NEW.DEL_USER='' and SHENPISTATUS='1'"; $query = "SELECT * from RMS_FILE_NEW where RMS_FILE_NEW.shenpiren='".$_SESSION["LOGIN_USER_ID"]."' and RMS_FILE_NEW.DEL_USER='' and SHENPISTATUS='1'"; //echo $query1."<br>"; if($FIELD==""){ $query.=" order by RMS_FILE_NEW.ADD_TIME DESC,RMS_FILE_NEW.MOD_TIME DESC"; } else { $query .= " order by $FIELD"; if($ASC_DESC=="1") $query .= " desc"; else $query .= " asc"; } //echo $query; $query .= " limit $start,$ITEMS_IN_PAGE"; if($ASC_DESC=="0") $ORDER_IMG="<img border=0 src=https://www.jb51.net/article/\"".MYOA_STATIC_SERVER."/static/images/arrow_up.gif\" width=https://www.jb51.net/article/\"11\" height=https://www.jb51.net/article/\"10\">"; else $ORDER_IMG="<img border=0 src=https://www.jb51.net/article/\"".MYOA_STATIC_SERVER."/static/images/arrow_down.gif\" width=https://www.jb51.net/article/\"11\" height=https://www.jb51.net/article/\"10\">"; ?> <table> <form action="?" method="post"> <tr> <td nowrap><input type="checkbox"></td> <td nowrapFILE_CODE") echo 1-$ASC_DESC;else echo "1";?>');"><u><?=_("文件号")?></u><?if($FIELD=="FILE_CODE") echo $ORDER_IMG;?></td> <td nowrapFILE_TITLE") echo 1-$ASC_DESC;else echo "1";?>');"><u><?=_("文件标题")?></u><?if($FIELD=="FILE_TITLE") echo $ORDER_IMG;?></td> <td nowrap><?=_("密级")?></td> <td nowrapSEND_UNIT"||$FIELD=="") echo 1-$ASC_DESC;else echo "1";?>');"><u><?=_("发文单位")?></u><?if($FIELD=="SEND_UNIT"||$FIELD=="") echo $ORDER_IMG;?></td> <td nowrapSEND_DATE") echo 1-$ASC_DESC;else echo "1";?>');"><u><?=_("发文时间")?></u><?if($FIELD=="SEND_DATE") echo $ORDER_IMG;?></td> <td nowrap><?=_("所属案卷")?></td> <td nowrap><?=_("创建人")?></td> <td nowrap><?=_("操作")?></td> </tr> <? $cursor= exequery(TD::conn(),$query, $connstatus); $RMS_FILE_NEW_COUNT=0; while($ROW=mysql_fetch_array($cursor)) { $RMS_FILE_NEW_COUNT++; $FILE_ID=$ROW["FILE_ID"]; $FILE_CODE=$ROW["FILE_CODE"]; $FILE_TITLE=$ROW["FILE_TITLE"]; $SECRET=$ROW["SECRET"]; $SEND_UNIT=$ROW["SEND_UNIT"]; $SEND_DATE=$ROW["SEND_DATE"]; $URGENCY=$ROW["URGENCY"]; $ROLL_ID=$ROW["ROLL_ID"]; $ADD_USER=$ROW["ADD_USER"];$ADD_TIME=$ROW["ADD_TIME"]; $query1 = "SELECT * from RMS_ROLL where ROLL_ID='$ROLL_ID'"; $cursor1= exequery(TD::conn(),$query1); if($ROW=mysql_fetch_array($cursor1)) { $ROLL_NAME=$ROW["ROLL_NAME"]; $STATUS=$ROW["STATUS"]; } else { $ROLL_NAME=""; } if($SEND_DATE=='0000-00-00') $SEND_DATE=''; $FILE_TITLE=htmlspecialchars($FILE_TITLE); $SECRET=get_code_name($SECRET,"RMS_SECRET"); $URGENCY=get_code_name($URGENCY,"RMS_URGENCY"); if($RMS_FILE_NEW_COUNT%2==1) $TableLine="TableLine1"; else $TableLine="TableLine2"; ?> <tr> <td nowrap> <? if($STATUS!=1) { ?> <input type="checkbox" value="<?=$FILE_ID?>"></td> <? } else echo " "; ?> <td nowrap> <a href="javascript:open_file('<?=$FILE_ID?>');"><?=$FILE_CODE?></a> </td> <td><a href="javascript:open_file('<?=$FILE_ID?>');"><?=$FILE_TITLE?></a></td> <td nowrap><?=$SECRET?></td> <td nowrap><?=$SEND_UNIT?></td> <td nowrap><?=$SEND_DATE?></td> <td nowrap><?=$ROLL_NAME?></td> <td nowrap><?=substr(getUserNameById($ADD_USER),0,-1);?></td> <td nowrap> <? if($STATUS!=1) { ?> <a href="modify.php?FILE_ID=<?=$FILE_ID?>&start=<?=$start?>"> <?=_("去审批")?></a> <? } else echo _("案卷已封"); ?> <a href="javascript:delete_file('<?=$FILE_ID?>','<?=$CUR_PAGE?>');"> <?=_("销毁")?></a> </td> </tr> <? } ?> <tr> <td colspan="9"> <b><?=_("文件操作:")?></b> <input type="button" value="<?=_("批量销毁")?>" title="<?=_("销毁已选中文件")?>"> <input type="button" value="<?=_("批量审批")?>" title="<?=_("批量审批已选中文件")?>"> </td> </tr> </form> </table> </body> </html>