0

我有一个表格,显示来自公共/文件夹的所有文件,

格式名称为 1_CCA-2018-0182224-720422085426

  1. 1_CCA-2018-0182224这是帐户 ID

  2. 720422085426这是 ID NO

当用户选中复选框时,我想将文件名保存到 2 列(帐户 ID 和 ID NO)
我使用隐藏来获取 ID NO 值,但问题是 ID NO 的值与文件名不匹配,

如果我加厚最后一条记录,ID NO 将在最后一条记录之前保存 ID NO,

但是如果第一个记录很厚,ID NO 保存正确,

谁能帮我?

<table id="dataTable" class="table table-bordered table-condensed table-hover table-striped" width="100%" border="1">
    <thead>
    <tr>
        <th width="5%">No</th>
        <th width="45%">Account ID & ID No</th>
        <th data-checkbox="true" width="5%"></th>
    </tr>
    </thead>
    <tbody>
    <?php $i = 1; ?>
    <tr>
        <td>1</td>
        <td>123</td>
        <td>
            <input type="checkbox" name="account_id[]" value="{{ substr($file,10,18) }}">
            <input type="hidden" name="file[]" value="{{$file}}">
            <input type="hidden" name="id[]" value="{{ substr($file,29,12) }}">
        </td>

    </tr>
    <tr>
        <td>2</td>
        <td>1234</td>
        <td>
            <input type="checkbox" name="account_id[]" value="{{ substr($file,10,18) }}">
            <input type="hidden" name="file[]" value="{{$file}}">
            <input type="hidden" name="id[]" value="{{ substr($file,29,12) }}">
        </td>

    </tr>
    <?php $i++; ?>
    </tbody>
</table>

4

1 回答 1

0

您应该能够使用以下方法同步数据检索:

foreach($request->id as $key => $value) {
    $id = $value;
    $file = $request->file[$key];
    $accountId = $request->account_id[$key] ?? null;
    if ($accountId) {
        // do stuff if checkbox was ticked
    } else {
        // do stuff if checkbox wasn't ticked            
    }
}
于 2018-08-06T06:53:36.283 回答