duanlian1960 2015-12-09 14:27
浏览 49
已采纳

在jquery php codeigniter中动态创建输入字段值

I am trying to get value from dynamic created input field But its not display nothing in page controller.

jQuery code to append dynamic the input

  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);

In the controller I try more then codes but nothing to display

I try to do that:

    $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";
  }

The array exist but empty not value of $k

And I try that

var_dump($this->input->post('des'));

the same nothing display

</div>
  • 写回答

1条回答 默认 最新

  • dongsi073898 2015-12-09 14:37
    关注

    Same variables in loop??, it might have overwritten the value posted from form

    foreach ($in as $in => $k) {
                     ^
      echo "Owner Name is : " . $k . "<br/>";
    }
    

    Try changing it to

    foreach ($in as $in1 => $k) {     
      echo "Owner Name is : " . $k . "<br/>";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料