first commit
This commit is contained in:
90
app/index.html
Normal file
90
app/index.html
Normal file
@@ -0,0 +1,90 @@
|
||||
<!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>
|
||||
Reference in New Issue
Block a user