Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
priyavratamohan authored Jun 13, 2024
1 parent 3c52224 commit 44ebe9f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions public/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const newInputButton = document.getElementById('newInputButton');
const inputText = document.getElementById('inputText');
const resultsDiv = document.getElementById('results');

// Fetch and display the last 5 inputs
// Fetch and display the saved inputs
async function fetchInputs() {
const response = await fetch('/inputs');
const inputs = await response.json();
Expand Down Expand Up @@ -37,9 +37,10 @@ const newInputButton = document.getElementById('newInputButton');
inputList.appendChild(li);
});
}

newInputButton.addEventListener('click', async () => {
document.getElementById("inputText").value="";
resultsDiv.innerHTML = "";
alert("Text area is cleared, you can add you new input now!");
fetchInputs();
});
Expand Down Expand Up @@ -107,4 +108,4 @@ const newInputButton = document.getElementById('newInputButton');
});

// Fetch inputs on page load
fetchInputs();
fetchInputs();

0 comments on commit 44ebe9f

Please sign in to comment.