我试图从动态创建的输入字段中获取值,但它在页面 Controller 中不显示任何内容。
附加动态输入的 jQuery 代码
var tableRow='<tr>';
tableRow+='<th><input type="text" class="form-control" name="ar[]" placeholder="Nom Articel" id="ar-'+i+'"></th>';
tableRow+='<th><input type="text" class="form-control" name="des[]" id="des-'+i+'" placeholder="Description"></th>';
$('#' + tableID + ' tbody').append(tableRow);
在 Controller 中,我尝试了更多代码,但没有显示任何内容
我尝试这样做:
$in=$this->input->post("des");
if (is_array($in)) {
foreach ($in as $in => $k) {
echo "Owner Name is : " . $k . "<br/>";
}
} else {
echo "Owner is not array";
}
数组存在但为空,不是 $k 的值
我尝试一下
var_dump($this->input->post('des'));
同样没有显示
最佳答案
循环中的相同变量??,它可能覆盖了从表单发布的值
foreach ($in as $in => $k) {
^
echo "Owner Name is : " . $k . "<br/>";
}
尝试将其更改为
foreach ($in as $in1 => $k) {
echo "Owner Name is : " . $k . "<br/>";
}
关于javascript - jquery php codeigniter 中动态创建的输入字段值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34181259/