Javascript 如何在PHP中使用post内部循环数据方法向控制器发送数据
我想使用form方法将数据发布到detail controller,它需要来自上一个视图的一些数据 我的看法是:Javascript 如何在PHP中使用post内部循环数据方法向控制器发送数据,javascript,php,html,loops,codeigniter,Javascript,Php,Html,Loops,Codeigniter,我想使用form方法将数据发布到detail controller,它需要来自上一个视图的一些数据 我的看法是: <form role="form" action="<?php echo URL_CTR;?>general/do_performance/detail" method="post"> <div role="tabpanel" class="tab-pane fade in active" id="per_provinsi">
<form role="form" action="<?php echo URL_CTR;?>general/do_performance/detail" method="post">
<div role="tabpanel" class="tab-pane fade in active" id="per_provinsi">
<h3 style="margin: 30px 0px 0px 0px;" class="text-center" id="title_do_1">Performance by <?php echo lang('gen.province.text');?></h3>
<table class="table mb0 table-striped" id="table_1" class="table_width">
<thead>
<tr>
<th style="width: 1%;"><?php echo lang('gen.no.text');?></th>
<th>Plant</th>
<th><?php echo lang('gen.province.text');?></th>
<th style="width: 10%;">Total DO</th>
<th style="width: 10%;">DO tidak terlambat</th>
<th style="width: 15%;">Lead Time Performance</th>
<th style="width: 5%;"><?php echo lang('gen.option.text');?></th>
</tr>
</thead>
<tbody id="data_1">
</tbody>
</table><br>
</div>
</form
但结果显示for数据的最后一个(plant_id 104和param_id 891是循环的最后一个数据):
在“for”循环中,如何在单击按钮的同一行时仅发送数据?更改各个字段的名称以使用数组,因此
plant\u id
应为plant\u id[]
下面是更新后的代码的样子
<input type="hidden" name="plant_id[]" value="'+data[i].gudang_id+'">\
<input type="hidden" name="param_id[]" value="'+data[i].provinsi_id+'">\
<input type="hidden" name="code[]" value="1">\
\
\
\
您可以像当前一样读取控制器中的值。现在它将是一个
数组
而不是字符串
更改各个字段的名称以使用数组,因此工厂id
应该是工厂id[]
下面是更新后的代码的样子
<input type="hidden" name="plant_id[]" value="'+data[i].gudang_id+'">\
<input type="hidden" name="param_id[]" value="'+data[i].provinsi_id+'">\
<input type="hidden" name="code[]" value="1">\
\
\
\
您可以像当前一样读取控制器中的值。它现在将是一个数组
,而不是字符串
{
plant_id: "104", //this is the last data in looping for
code: "1",
param_id: "891", //this is the last data in looping for
}
<input type="hidden" name="plant_id[]" value="'+data[i].gudang_id+'">\
<input type="hidden" name="param_id[]" value="'+data[i].provinsi_id+'">\
<input type="hidden" name="code[]" value="1">\