dsg41888 2011-08-13 22:49
浏览 63
已采纳

使用php上的jquery对话框编辑数据

How do I create an edit dialog box using jquery? Let say I have a html table full of data, and if I click on a button on a row, it will display the data on that row into a jquery dialog box.

I am able to create a dialog box to add data and to remove data, but to edit data and populate the textboxes on the jquery, I am really out of idea.

  • 写回答

2条回答 默认 最新

  • dprlv04662 2011-08-13 23:29
    关注

    You can have a edit button in the last cell of each row

    <input type="button" calss="edit" value="Edit" />
    

    On click of this button get all the cells data of this row and pass it to dialog box.

    $("input.each").click(function(){
    
      var tr = $(this).closes("tr");
      var data = [];
      tr.find("td:not(:last)").each(function(){
         data.push($(this).text());
      });
    
      //Here open the dialog box which will have the required fields and using the above data array populate the data fields as required
    
      //Lets say the first column in the table is for "Name"
      //You can populate the input "Name" field in the dialog box as.
      $("input[name=Name]").val(data[0]);
    
      //Similarly populate all the data fields using data array
    
    });
    

    The dialog box will also have a Save button on click of which it will update the cells of the current row with edited data.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!