forked from DanyalAhmad2003/HCI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-device-step1.html
More file actions
38 lines (37 loc) · 1.58 KB
/
add-device-step1.html
File metadata and controls
38 lines (37 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>EcoBin – Add Device (1)</title>
<link rel="stylesheet" href="css/styles.css" />
</head>
<body>
<header><h1>Adding a new device into the EcoBin system wizard</h1></header>
<main>
<form id="step1" action="add-device-step2.html" method="get">
<p>What materials is the device made out of?</p>
<label><input type="checkbox" name="material" value="Plastics"> Plastics</label><br>
<label><input type="checkbox" name="material" value="Metals"> Metals</label><br>
<label><input type="checkbox" name="material" value="Glass"> Glass</label><br>
<label><input type="checkbox" name="material" value="Other"> Other</label><br>
<textarea name="otherMaterial" placeholder="Write your response" rows="3" style="width:100%;"></textarea>
<button type="submit" class="btn">Next →</button>
</form>
</main>
<a href="business.html" class="back-btn">← Back</a>
<script>
document.getElementById('step1').addEventListener('submit', e => {
e.preventDefault();
// grab checked materials
const mats = Array.from(document.querySelectorAll('input[name="material"]:checked'))
.map(cb => cb.value);
const other = document.querySelector('textarea[name="otherMaterial"]').value.trim();
if (other) mats.push(other);
localStorage.setItem('ecoMaterials', JSON.stringify(mats));
// go to next step
window.location = e.target.action;
});
</script>
</body>
</html>