-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path02-search.html
34 lines (32 loc) · 1005 Bytes
/
02-search.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>세션 스토리지에 구입 리스트 저장</title>
<script>
function search() {
if (!window.sessionStorage) {
alert("지원하지 않습니다.");
return;
}
let item = document.getElementById("item").value;
let count = sessionStorage.getItem(item);
if (count == null) {
alert(item + " 항목이 없습니다.");
return;
}
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"></label>
<input type="button" value="검색" onclick="search()">
</form>
</body>
</html>