我有一个页面,显示使用codeigniter创建的用户的每月订阅。我想要做的是当用户点击付款时将隐藏文件中的值传递给控制器。将相关隐藏字段值从表单传递到控制器
<?php echo form_open('options/done');?>
<table class="tables">
<thead>
<tr>
<th>Ref Code</th>
<th>Month</th>
<th>Year</th>
<th>action/th>
</tr>
</thead>
<tbody>
<?php foreach ($payments as $s =>$payment):?>
<?php $month = $payment['month'];?>
<input type="hidden" value="<?php echo $month;?>" name="month_<?php echo $s;?>" />
<input type="hidden" value="<?php echo $payment['ref_code'];?>" name="ref_<?php echo $s;?>" />
<tr>
<td><?php echo $payment['ref_code'];?></td>
<td><?php echo $month;?></td>
<td><?php echo $payment['year'];?></td>
<td><input type="submit" value="MAKE PAYMENT" class="red" /></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php echo form_close();?>
所以当有人点击了提交按钮,我怎么能只传递这是有关该表行中的隐藏价值?
移动你的表单标签进入foreach循环和incremenet形式ID名称呢? – Dave
@Dave可以在表格内使用表格标签吗? – LiveEn
绝对,见下面 – Dave