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 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退