Javascript 删除表行
今天我有一个关于如何删除tablerow的问题。 我有一个表,其中表行由foreach从数据库中填充数据。 下面你可以看到我使用的foreach填充表格行 **我希望当您通过selectbutton选择行并单击“删除”按钮时,该行将从数据库中删除。 **我希望有人能帮我Javascript 删除表行,javascript,php,mysql,dom,Javascript,Php,Mysql,Dom,今天我有一个关于如何删除tablerow的问题。 我有一个表,其中表行由foreach从数据库中填充数据。 下面你可以看到我使用的foreach填充表格行 **我希望当您通过selectbutton选择行并单击“删除”按钮时,该行将从数据库中删除。 **我希望有人能帮我 $oSelect = new creatorwebsite(); $cWebsites = creatorwebsite::get($oSelect); foreach($cWebsites as $oWebs
$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
$(文档).ready(函数(){
var id=$(“您的_id”).val()
$(“您的按钮”)。单击(函数(){
$.ajax({
}))
delete.php
建立数据库连接并
在此页面中执行删除过程,并返回结果“成功或失败”
我不需要对selectbox执行任何操作,以便它知道选中了哪一行吗?如果要对selectbox执行操作,可以使用change()函数而不是click()函数
type : "POST",
url : "delete.php",
data : "id=" + id,
error : function(){
},
success : function(response){
if(response == 'success'){
location.reload();
}
}
});
});