0

嗨:我有一个旧的 php4 应用程序,我们仍然有几个客户在使用。一位客户希望在列表页面中添加一项功能,允许他们选择多个工作,然后一键删除选择的工作。

我想在当前第一列的左侧添加一列,其中包含一个复选框,用户选择任意数量的复选框,然后单击删除,删除 5、8、20 个复选框,在这种情况下实际存档。

所以我基本上想要在这个代码库中应用 gmail 中的类似功能。

任何帮助,将不胜感激。

这是吐出工作列表页面的代码

function getRequest(rn)
{
    document.forms.intake.R_NUMBER.value=rn;
    goTo('WHOLEBRIEF','display');
}

function archiveRequest(rn)
{
    if(confirm('Are you sure you want to remove this request?'))
    {
        document.forms.intake.R_NUMBER.value=rn;
        goTo('LIST','remove');
    }
}

</script>

<SCRIPT LANGUAGE="JavaScript" SRC="include/table.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="include/jquery.js"></SCRIPT>
<style type="text/css">
th.table-sortable {
    cursor:pointer;
    background-image:url("/images/sortable.gif");
    background-position:center left;
    background-repeat:no-repeat;
    padding-left:12px;
}
th.table-sorted-asc {
    background-image:url("/images/sorted_up.gif");
    background-position:center left;
    background-repeat:no-repeat;
}
th.table-sorted-desc {
    background-image:url("/images/sorted_down.gif");
    background-position:center left;
    background-repeat:no-repeat;
}
tr.alternates {
    background-color:#f0f0f0;
}
</style>
<input type="hidden" name="JOB_NUMBER">
 <center>
<table class="jobs" width="700" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<label>Show All Jobs</label>

<table width="1150" style="border: 1px solid #660099;" class="jobs sort01 table-autosort table-autofilter table-stripeclass:alternate table-filtered-rowcount:t1filtercount">
<thead>
<tr bgcolor="#cccccc" align="center">
<th width="50"  class="table-sortable:numeric"><label>Number</label></td>
<th width="200" class="table-filterable table-sortable:default"><label>Requested By</label></td>
<th width="200" class="table-sortable:default"><label>Project Name</label></td>
<th width="200" class="table-filterable table-sortable:default"><label>Project Category</label></td>
<th width="200" class="table-filterable table-sortable:default"><label>Job Type</label></td>  
<th width="150" class="table-sortable:date"><label>Date Submitted</label></td>
<th width="150" class="table-sortable:date"><label>Due Date</label></td>
<th width="100" class="table-filterable table-sortable:default"><label>Status</label></td>
<th width="20">&nbsp;</td>
</tr>
</thead>
<?

$i=0;
if(is_array($R)):
foreach ($R as $key=>$val):?>
<tr bgcolor="<?=getBGC($i)?>">
<td><a href="#" onclick="getReqs('<?=$R[$key]['JOB_NUMBER']?>');return false;"><?=$key?></a></td>
<td><?=$R[$key]['ANSWER']['Q_2']?></td><!--requestor name-->
<td><?=$R[$key]['ANSWER']['Q_5']?></td><!--project name-->
<td><?=$R[$key]['ANSWER']['Q_4']?></td><!--project category-->
<td><?=$R[$key]['ANSWER']['Q_25']?></td><!--job specs-->
<td align="center"><?=formatDate($R[$key]['R_DATE_SUBMITTED'],'y-m-d','m/d/y')?></td>
<td  align="center"><?=$R[$key]['ANSWER']['Q_22']?></td><!--due Date-->

<td  align="center"><?=lookupChange($R[$key]['R_STATUS'])?></td>
<td width="20">
    <?if($tKey):?>
       <a href="#" onclick="archiveRequest('<?=$R[$key]['JOB_NUMBER']?>');return false"><img src="images/b_close.gif" border="0"></a>
    <?endif;?>
    </td>
</tr>

<?$i++;endforeach;endif;?>
</table>  
</td>
</tr>
<tr><td>&nbsp;</td></tr>

</table>    </center>
4

1 回答 1

0

大招:添加名称以[]结尾的复选框。提交后,您将能够遍历多个结果并处理每个结果。

<input type="checkbox" name="archive[]" value="<?=$R[$key]['JOB_NUMBER']?>" />

使用表单提交这些值(看起来您可以将表格包装在表单中)。

在服务器端,您可以像这样循环遍历结果数组:

if(!empty($_POST['archive'])) {
    foreach($_POST['archive'] as $archiveId) {
        echo $archiveId;
        // archive the values specified
    }
}
于 2013-01-07T21:33:44.737 回答