From 93229c27955d1a12ba3305adcfbb41f5cc91a351 Mon Sep 17 00:00:00 2001 From: mms37 Date: Sun, 19 Jun 2022 18:32:06 -0700 Subject: [PATCH] Testing --- data.db | 2 +- public/index.html | 2 +- public/script.js | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/data.db b/data.db index 2bd27ef..677c3ef 100644 --- a/data.db +++ b/data.db @@ -1,2 +1,2 @@ -{"name":"n0","weight":"80","height":"5","hairColour":"red","gpa":"0","_id":"C7MLNJ6FdWLGty5T"} +{"name":"n0","weight":"80","height":"5","hairColour":"red","gpa":"2","_id":"C7MLNJ6FdWLGty5T"} {"name":"n1","weight":"99","height":"180","hairColour":"pink","gpa":"2","_id":"EZ5eUBQmH2I1bUov"} diff --git a/public/index.html b/public/index.html index 54f07a1..d420d06 100644 --- a/public/index.html +++ b/public/index.html @@ -8,7 +8,7 @@
- +
diff --git a/public/script.js b/public/script.js index aae86d8..c7926ba 100644 --- a/public/script.js +++ b/public/script.js @@ -5,6 +5,22 @@ window.onload = function () { table.style.display = "none" edit = document.getElementById("editForm"); edit.style.display = "none"; + document.getElementById('editStudent').addEventListener("click", async (event) => { + event.preventDefault(); + var response = await fetch('/student'); + var students = await response.json(); + var sName = document.getElementById("findName").value; + for (s of students) { + if (sName == s.name) { + edit.style.display = "inline-block" + document.getElementById("editName").innerHTML = s.name; + document.getElementById("editWeight").value = s.weight; + document.getElementById("editHeight").value = s.height; + document.getElementById("editHairColour").value = s.hairColour; + document.getElementById("editGpa").value = s.gpa; + } + } + }); displayStudents(); }