这里表的 id 是从删除按钮传递的。但我无法从数据库和表中删除记录。这是代码:
function deleteRow(tableID) {
try {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
for(var i=0; i<rowCount; i++) {
var row = table.rows[i];
var chkbox = row.cells[0].childNodes[0];
if(null !== chkbox && true === chkbox.checked) {
table.deleteRow(i);
var did;
id=request.getParameter("check"+i);
out.println(did);
}
rowCount--;
i--;
}
}
catch(e) {
alert(e);
}
}
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/jspdatabase","root", "kca@fnpl#12");
st=con.createStatement();
st.executeUpdate("delete from table1 where id ='"+did+"'");