-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice12-2-search.html
More file actions
35 lines (32 loc) · 1.09 KB
/
practice12-2-search.html
File metadata and controls
35 lines (32 loc) · 1.09 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>세션 스토리지에서 구입 리스트 검색</title>
<script>
function search() {
if (!window.sessionStorage) {
alert("세션 스토리지를 지원하지 않습니다.");
return;
}
const item = document.getElementById("item").value.trim();
const count = sessionStorage.getItem(item);
if (count === null) {
alert(`${item}는 구입 리스트에 없습니다.`);
} else {
document.getElementById("count").value = count;
}
}
</script>
</head>
<body>
<h3>세션 스토리지에서 구입 리스트 검색</h3>
<hr>
<form>
<label>품목명: <input id="item" type="text" size="10"></label>
<label>개수: <input id="count" type="text" size="10" readonly></label>
<input type="button" value="검색" onclick="search()">
</form>
</body>
</html>