我需要使用HTML,Javascript和CSS制作CRUD应用程序
现在的问题是图像(ktpFile),现在如果我添加新数据,则表中仅显示图像的路径。 image
如何在表格中显示图像?
var selectedRow = null
function onFormSubmit() {
var formData = readFormData();
if (selectedRow == null)
insertNewRecord(formData);
else
updateRecord(formData);
resetForm();
}
function readFormData() {
var formData = {};
// ...
formData["ktpFile"] = document.getElementById("ktpFile").value;
return formData;
}
function insertNewRecord(data) {
var table = document.getElementById("employeeList").getElementsByTagName('tbody')[0];
var newRow = table.insertRow(table.length);
// ...
cell6.innerHTML = data.ktpFile;
cell6 = newRow.insertCell(6);
cell6.innerHTML = `<a onClick="onEdit(this)">Edit</a>
<a onClick="onDelete(this)">Delete</a>`;
}
function onEdit(td) {
// ...
document.getElementById("ktpFile").value = selectedRow.cells[5].innerHTML;
}
function updateRecord(formData) {
// ...
selectedRow.cells[5].innerHTML = formData.ktpFile;
}