Compare commits

..
2 Commits
Author SHA1 Message Date
Technoir 9b912375c9 added index.js
website can now add items to buy
2026-09-28 14:23:51 +02:00
Technoir 62ef46fa01 added index.html
website has now a form to add items and will display these items aswell
2026-09-28 14:23:19 +02:00
2 changed files with 48 additions and 0 deletions

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Einkaufsliste</title>
<link href="css/style.css" rel="stylesheet">
<script src="js/index.js" defer></script>
</head>
<body>
<div class="title">
</div>
<div class="list">
<form class="list__inputForm">
<input type="text" class="list__inputForm__itemName" name="nameOfItem">
<input type="text" name="amountOfItem" class="list__inputForm__itemAmount">
<button class="list__inputForm__submitButton" type="submit">Hinzufügen</button>
</form>
<ul class="list__displayedList">
</ul>
</div>
</body>
</html>
+20
View File
@@ -0,0 +1,20 @@
const date = document.createElement("h1");
date.textContent = "Einkaufsliste vom: " + new Date().toLocaleString('de');
const host = document.querySelector(".title")
host.appendChild(date);
document.querySelector(".list__inputForm").addEventListener("submit", (event) => {
event.preventDefault();
addListElement();
});
function addListElement() {
var itemName = document.querySelector(".list__inputForm__itemName").value;
var itemAmount = document.querySelector(".list__inputForm__itemAmount").value;
var list = document.querySelector(".list__displayedList");
const newListElement = document.createElement("li");
newListElement.textContent = itemName + " " + itemAmount;
list.appendChild(newListElement);
return 0;
}