【问题标题】:On Button Click save Table Row and open another link with the saved ID [closed]在按钮上单击保存表行并使用保存的 ID 打开另一个链接 [关闭]
【发布时间】:2017-08-18 12:34:37
【问题描述】:

在上图中,我有一行数据是手动添加的。我正在寻找一种可以让我执行以下操作的解决方案:

  1. 点击配置按钮将整行保存到表格中。
  2. 保存后读取插入的 id 并在 queryString 中打开具有该 id 的另一个 URL。

这意味着一旦记录被保存,它就会打开另一个插入的 id 在查询 Sting 中的位置,以将保存的数据读入新打开的页面。

我的上述期望可能吗?如果是,那么请指导整个代码。

同样需要通过 jquery、Ajax 和 PHP 来完成

【问题讨论】:

  • 简单的答案,是的,这是可能的。但是我不认为这是其他人为您编写代码的地方。你至少应该展示你所拥有的(如果你有的话)。

标签: javascript php jquery mysql ajax


【解决方案1】:

album,artist,year,origin,price an id 然后使用jquery;

$("#buttonId").click(function(e){

  //pick all the row details
  var album = $(this).closest("tr").find("#albumId").text();
  var artist = $(this).closest("tr").find("#artistId").text();
  var year = $(this).closest("tr").find("#YearId").text();
  var origin = $(this).closest("tr").find("#OriginId").text();
  var price = $(this).closest("tr").find("#priceId").text();

  //use ajax to update a form with the values you want to save to the database
   $.ajax({
            url : "insert.php",
            method: "POST",
            data: {"album":album, "artist":artist, "year":year, "origin":origin, "price":price},
            dataType:"text",
            success:function(returnedId){
                //success code open a website with the id
                window.open("new_page.php?id="+returnedId');
            }
        });

});

【讨论】:

  • 您可以创建 insert.php 页面以接受并将详细信息保存到数据库。我已经给了你剩下的 95% 你可以做到
  • 我认为他们想获得一些回购,因此发布此类问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-10-24
  • 1970-01-01
相关资源
最近更新 更多