Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions function.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
window.addEventListener('DOMContentLoaded', function () {
var formSubmit = document.forms[1]
formSubmit.addEventListener('submit', (e) => {
e.preventDefault();

var oldItems = JSON.parse(localStorage.getItem('records')) || [];
var newItem = {
category: formSubmit['category'].value,
date: formSubmit['date'].value,
amount: formSubmit['amount'].value,
description: formSubmit['description'].value,
};

oldItems.push(newItem)

localStorage.setItem('records', JSON.stringify(oldItems));


formSubmit['category'].value = '';
formSubmit['date'].value = '';
formSubmit['amount'].value = '';
formSubmit['description'].value = '';
})
})
4 changes: 1 addition & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<title></title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<script src="function.js"></script>
<style>
tr .remove{
visibility: hidden;
Expand Down Expand Up @@ -125,9 +126,6 @@ <h5>記個帳吧</h5>
</div>

</div>
<script src="index.js"></script>
<script src="search.js"></script>
<script src="init.js"></script>
</body>

</html>