Calculator Tools Calculator Tools
Create

Household Account Book

Oct 12, 2023

About this app

A simple and effective household account book app to manage your expenses and incomes.

Household Account Book 🏠 Household Account Book Income Expense Add Type Description Amount

Related apps

Put this on your site

Source

                    <html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">

<title>Household Account Book</title>
<meta name="description" content="A simple and effective household account book app to manage your expenses and incomes.">
<meta name="keywords" content="Household, Account Book, Expenses, Incomes, Management">

<link href="https://fonts.googleapis.com/css2?family=Playfair+Display&family=Roboto&display=swap" rel="stylesheet">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

<script type="text/javascript">
try {
let accountBook = [];

function loadLocal() {
const savedData = localStorage.getItem('accountBook');
if (savedData) {
accountBook = JSON.parse(savedData);
displayData();
}
}

function saveLocal() {
localStorage.setItem('accountBook', JSON.stringify(accountBook));
}

function addData(e) {
e.preventDefault();
let type = document.querySelector('#type').value;
let description = document.querySelector('#description').value;
let amount = document.querySelector('#amount').value;
accountBook.push({ type, description, amount });
saveLocal();
displayData();
}

function displayData() {
let output = document.querySelector('#output');
output.innerHTML = '';
accountBook.forEach((data, index) => {
let row = document.createElement('tr');
row.innerHTML = `<td>${data.type}</td><td>${data.description}</td><td>${data.amount}</td>`;
output.appendChild(row);
});
}

document.addEventListener("DOMContentLoaded", function() {
loadLocal();
document.querySelector('#add').addEventListener('click', addData);
});

} catch (error) {
throw error;
}
</script>

<style>
body {
font-family: 'Roboto', sans-serif;
background: linear-gradient(to right, #83a4d4, #b6fbff);
}
h1 {
font-family: 'Playfair Display', serif;
text-align: center;
color: #333;
}
table {
width: 100%;
margin-top: 20px;
}
table, th, td {
border: 1px solid #333;
border-collapse: collapse;
}
th, td {
padding: 15px;
text-align: left;
}
th {
background-color: #4CAF50;
color: white;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<h1>🏠 Household Account Book</h1>
<form>
<select id="type">
<option value="Income">Income</option>
<option value="Expense">Expense</option>
</select>
<input type="text" id="description" placeholder="Description">
<input type="number" id="amount" placeholder="Amount">
<button id="add">Add</button>
</form>
<table>
<tr>
<th>Type</th>
<th>Description</th>
<th>Amount</th>
</tr>
<tbody id="output"></tbody>
</table>
</div>
</body>
</html>