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/>";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 如图:直线与椭圆X轴平行,求直线与椭圆任意一点的相切坐标计算公式
  • ¥50 如何用python使用opencv里的cv::cudacodec::VideoWriter函数对视频进行GPU硬编码
  • ¥100 c#solidworks 二次开发 工程图自动标边线法兰 等折弯尺寸怎么标
  • ¥15 halcon DrawRegion 提示错误
  • ¥15 FastAPI Uvicorn启动显示404
  • ¥15 centos7.9脚本,怎么排除特定的访问记录
  • ¥15 关于#Django#的问题:我的静态文件呢?
  • ¥15 关于CPLEX的问题,请专家解答
  • ¥15 cocos的点击事件 怎么穿透到 原生fragment上。
  • ¥20 基于相关估计的TDOA算法中的加权最小二乘拟合法matlab仿真