Files
ali-cicd/app/index.html
2026-04-02 15:13:15 +05:30

91 lines
1.9 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Number Logger</title>
<style>
body {
font-family: Arial;
text-align: center;
padding: 20px;
}
input, button {
width: 90%;
padding: 12px;
margin: 10px;
font-size: 18px;
}
button {
background: #28a745;
color: white;
border: none;
}
ul {
list-style: none;
padding: 0;
}
li {
background: #f1f1f1;
margin: 5px;
padding: 10px;
}
</style>
</head>
<body>
<h2>Enter Number</h2>
<input type="number" id="number" placeholder="Enter number">
<button onclick="submitData()">Submit</button>
<p id="status"></p>
<h3>Saved Numbers</h3>
<ul id="list"></ul>
<script>
function loadData() {
fetch("read.php")
.then(res => res.json())
.then(data => {
let list = document.getElementById("list");
list.innerHTML = "";
data.reverse().forEach(item => {
let li = document.createElement("li");
li.innerText = item.number;
list.appendChild(li);
});
});
}
function submitData() {
let number = document.getElementById("number").value;
if (!number) {
alert("Enter a number");
return;
}
fetch("save.php", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: `number=${number}`
})
.then(res => res.text())
.then(data => {
document.getElementById("status").innerText = data;
document.getElementById("number").value = "";
loadData(); // refresh list
});
}
// Load data on page open
loadData();
</script>
</body>
</html>