douxiza9868 2013-11-16 15:02
浏览 29
已采纳

如何在不使用CodeIgniter中的输入的情况下一次插入多行?

How to insert the datas from a <table> rows into the database without any <input> ?

In CodeIgniter, I have a function where I can generate random users, which are inserted into the <table>...</table> using an AJAX method by clicking on a $('#btnGenerate');

It fills out an empty table with the new table rows (<tr>). Here how it looks like:
Random user generator

Now when I want to save these new rows into the database, I don't know how to proceed. As far as I know, I need to have an array which will be then posted into the form's action: members/form_random for example with the $this->input->post('someInputName');?>. How can I do that if I don't use any <input> tags inside the table ?

Any advice for solution ?

  • 写回答

1条回答 默认 最新

  • douren0558 2013-11-27 05:54
    关注

    When you generate the random users, make sure you store each row in an object array like

    var arr = [
        {username:'abc',email:'abc@exmaple.org'},
        {username:'def',email:'def@exmaple.org'},
         .
         .
    ];
    

    And the trigger an onClick event from the Apply,Save Button to an AJAX function and send the array as JSON data to the controller that saves the data.

    I think this will sort out your problem..

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?