gpt4 book ai didi

javascript - 删除表格行

转载 作者:行者123 更新时间:2023-11-30 00:23:25 24 4
gpt4 key购买 nike

今天我有一个关于如何删除表格行的问题。我有一个表,其中表行由 foreach 填充来自数据库的数据。在下面你可以看到我使用 foreach 来填充表格行。

**我希望当您通过选择按钮选择行并单击“删除”按钮时,该行将从数据库中删除。** 我希望有人能帮助我解决这个问题

    $oSelect = new creatorwebsite();
$cWebsites = creatorwebsite::get($oSelect);

foreach($cWebsites as $oWebsite)
{
$oTr2 = $oPage->createElement('tr');
$oTr2->setAttribute('id', $oWebsite->getAttribute("website_id"));
$oTd = $oPage->createElement('td');
$oCheckbox = $oPage->createElement('input');
$oCheckbox->setAttribute('type', 'checkbox');
$oCheckbox->setAttribute('onclick','selectRow(this)');
$oTd->appendChild($oCheckbox);
$oTr2->appendChild($oTd);

$oTd = $oPage->createElement('td', $oWebsite->getAttribute("server_name"));
$oTr2->appendChild($oTd);
$oTd = $oPage->createElement('td', $oWebsite->getAttribute("klantnaam"));
$oTr2->appendChild($oTd);
$oTd = $oPage->createElement('td', $oWebsite->getAttribute("startdatum")->format('Y-m-d'));
$oTr2->appendChild($oTd);
$oTd = $oPage->createElement('td', $oWebsite->getAttribute("quota"));
$oTr2->appendChild($oTd);
$oTd = $oPage->createElement('td', $oWebsite->getAttribute("status"));
$oTr2->appendChild($oTd);
$oTd = $oPage->createElement('td', '(Edit)');
$oTd->setAttribute('class','editAction');
$oTd->setAttribute('id','editButton');

$oTr2->appendChild($oTd);
$oTable->appendChild($oTr2);
}

最佳答案

尝试ajax

$( document ).ready(function() {

var id = $("your_id").val();

$("your_button").click(function(){

$.ajax({

        type : "POST",
url : "delete.php",
data : "id=" + id,
error : function(){
       },
success : function(response){
if(response == 'success'){
location.reload();
}
}
});
});

});

delete.php establish your db connection and do the delete process here in this page and echo result "sucess or failure".

关于javascript - 删除表格行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23055085/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com