dongza3124 2011-09-09 03:16
浏览 82

使用javascript从动态html表保存数据

I load data from a mysql table into a HTML table. Then the user can add or remove one or more rows. Finally I have to save the changes into the database. All this have to be done using PHP and javascript.

I know this does not seem very hard. In fact, I managed to load data from database into the HTML table and add or remove rows from it, using javascript function but I'm having the hardest time trying to save changes from the table. How can I delete an specific row from the table, considering that these rows don't have id's since they are dynamically added? How can I access data from an specific row?

I hope you guys can help me out. This is driving me nuts! Thank you and sorry for my English.

  • 写回答

2条回答 默认 最新

  • dtz8044 2011-09-09 03:30
    关注

    If you are adding them dynamically can't you give the rows id's? Or maybe iterate through the table with javascript?

    var theTable = document.getElementById("theTableId");
    for (var i=0, row; row=table.rows[i]; i++) {
              // Remove if deleted
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?