From 341e4c8d6648ea8bbcbb7f5fa3b08a599ac595f2 Mon Sep 17 00:00:00 2001 From: Jerry Date: Wed, 19 Aug 2020 12:37:17 +0800 Subject: [PATCH 1/2] task1 finished --- function.js | 17 +++++++++++++++++ index.html | 4 +--- 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 function.js diff --git a/function.js b/function.js new file mode 100644 index 0000000..8fa2d51 --- /dev/null +++ b/function.js @@ -0,0 +1,17 @@ +window.addEventListener('DOMContentLoaded', function(){ + var formSubmit = document.forms[1] + formSubmit.addEventListener('submit', (e) => { + e.preventDefault(); + console.log({ + category: formSubmit['category'].value, + date: formSubmit['date'].value, + amount: formSubmit['amount'].value, + description: formSubmit['description'].value, + }) + + formSubmit['category'].value = ''; + formSubmit['date'].value = ''; + formSubmit['amount'].value = ''; + formSubmit['description'].value = ''; + }) +}) \ No newline at end of file diff --git a/index.html b/index.html index a31ec4b..9e12fd0 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,7 @@ +