0

我正在编写一个 PHP 代码,当页面运行时,它将显示带有更新按钮选项的动态记录。现在的问题是它是动态生成的,那么当单击按钮时如何获取表记录的特定 COLUMN 值?

4

1 回答 1

0

PHP创建表

    echo "<table>";
    echo "<tr>";

    while( ($row = mysql_fetch_array($result)))
    {
        echo "<td>".$row['no']."</td>";
        echo "<td>".$row['notify']."</td>";
        echo "<td>".$row['date']."</td>";
        echo "<td>".$row['url']."</td>";
        echo "<td><input type='button' name='update' onClick='updateRecord(this)' id='update' value='".$row['id']."'></td>";
    }

    echo "</tr>";
    echo "</table>";

JavaScript 更新记录

function updateRecord(id)
{
    var recordId = id.value;
     ...Update record through ajax call...
     ...Update record through form submit...

}

通过ajax调用更新记录

$.ajax({
        url: 'update.php',
        method: 'GET',
        data: 'userID=' + recordId,
        success: function(new_data){
             $(popID).html(new_data);
              $(popID).dialog();
              alert('Load was performed.');
        }
    });
于 2012-12-27T18:26:37.193 回答