File manager - Edit - /home/webapp68.cm.in.th/u68319090024/final/news/manage_articles.html
Back
<!DOCTYPE html> <html lang="th"> <head> <meta charset="UTF-8"> <title>จัดการบทความ</title> <style> body { font-family: Arial; margin:20px; background:#f4f4f4; } h1 { text-align:center; color:#333; } table { width:80%; margin:20px auto; border-collapse: collapse; background:#fff; } th, td { padding:10px; border:1px solid #ccc; text-align:center; } th { background:#007BFF; color:#fff; } button { padding:5px 10px; border:none; border-radius:5px; cursor:pointer; margin:2px; } .add { background:#28a745; color:#fff; } .edit { background:#ffc107; color:#fff; } .delete { background:#dc3545; color:#fff; } a { display:block; text-align:center; margin-top:20px; text-decoration:none; color:#007BFF; } </style> </head> <body> <h1>จัดการบทความ</h1> <button class="add" onclick="addArticle()">เพิ่มบทความ</button> <table id="articleTable"> <tr><th>ID</th><th>ชื่อบทความ</th><th>หมวดหมู่</th><th>Actions</th></tr> </table> <a href="index.html">กลับไป Dashboard</a> <script> let articles = window.opener.dataStore.articles; let categories = window.opener.dataStore.categories; function renderTable() { let table = document.getElementById("articleTable"); table.innerHTML = '<tr><th>ID</th><th>ชื่อบทความ</th><th>หมวดหมู่</th><th>Actions</th></tr>'; articles.forEach((a,i)=>{ let row = table.insertRow(); row.insertCell(0).innerText = i+1; row.insertCell(1).innerText = a.title; row.insertCell(2).innerText = a.category; row.insertCell(3).innerHTML = `<button class="edit" onclick="editArticle(${i})">แก้ไข</button> <button class="delete" onclick="deleteArticle(${i})">ลบ</button>`; }); window.opener.updateDashboard(); } function addArticle(){ let title = prompt("ชื่อบทความ:"); if(!title) return; let category = prompt("หมวดหมู่ (เลือกจาก: " + categories.join(", ") + "):"); if(!category) category="ทั่วไป"; articles.push({title, category}); renderTable(); } function editArticle(index){ let title = prompt("แก้ไขชื่อบทความ:", articles[index].title); if(title) articles[index].title = title; let category = prompt("แก้ไขหมวดหมู่:", articles[index].category); if(category) articles[index].category = category; renderTable(); } function deleteArticle(index){ if(confirm("คุณต้องการลบบทความนี้หรือไม่?")){ articles.splice(index,1); renderTable(); } } renderTable(); </script> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.45 |
proxy
|
phpinfo
|
Settings