<!DOCTYPE html>
<html lang="ar">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>إدخال بيانات الرسائل</title>
<style>
body {
font-family: Arial, sans-serif;
direction: rtl;
text-align: right;
padding: 20px;
}
.form-container {
margin-bottom: 20px;
}
label {
display: block;
margin: 5px 0;
}
input[type="text"], input[type="date"], button {
padding: 10px;
margin-bottom: 10px;
width: 100%;
box-sizing: border-box;
}
button {
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
table, th, td {
border: 1px solid #ddd;
padding: 8px;
}
th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<h2>إضافة تفاصيل الرسائل</h2>
<div class="form-container">
<label for="name">الاسم:</label>
<input type="text" id="name" placeholder="ادخل الاسم">
<label for="region">المنطقة:</label>
<input type="text" id="region" placeholder="ادخل المنطقة">
<label for="messageType">نوع الرسالة:</label>
<input type="text" id="messageType" placeholder="ادخل نوع الرسالة">
<label for="dateReceived">تاريخ استلام الرسالة:</label>
<input type="date" id="dateReceived">
<button onclick="addData()">إضافة</button>
</div>
<h2>معلومات الرسائل</h2>
<input type="text" id="searchInput" onkeyup="searchTable()" placeholder="ابحث عن البيانات">
<table id="dataTable">
<thead>
<tr>
<th>الاسم</th>
<th>المنطقة</th>
<th>نوع الرسالة</th>
<th>تاريخ الاستلام</th>
</tr>
</thead>
<tbody id="tableBody">
<!-- سيتم إضافة البيانات هنا -->
</tbody>
</table>
<script>
function addData() {
const name = document.getElementById("name").value;
const region = document.getElementById("region").value;
const messageType = document.getElementById("messageType").value;
const dateReceived = document.getElementById("dateReceived").value;
if (name && region && messageType && dateReceived) {
const tableBody = document.getElementById("tableBody");
const newRow = document.createElement("tr");
newRow.innerHTML = `
<td>${name}</td>
<td>${region}</td>
<td>${messageType}</td>
<td>${dateReceived}</td>
`;
tableBody.appendChild(newRow);
// مسح الحقول بعد الإضافة
document.getElementById("name").value = "";
document.getElementById("region").value = "";
document.getElementById("messageType").value = "";
document.getElementById("dateReceived").value = "";
} else {
alert("يرجى تعبئة جميع الحقول");
}
}
function searchTable() {
const searchInput = document.getElementById("searchInput").value.toLowerCase();
const tableRows = document.getElementById("tableBody").getElementsByTagName("tr");
for (let row of tableRows) {
let cells = row.getElementsByTagName("td");
let rowContainsQuery = false;
for (let cell of cells) {
if (cell.textContent.toLowerCase().includes(searchInput)) {
rowContainsQuery = true;
break;
}
}
row.style.display = rowContainsQuery ? "" : "none";
}
}
</script>
</body>
</html>