-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample9.html
57 lines (55 loc) · 1.47 KB
/
sample9.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8"/>
<title>Sample Page 9(配列との串刺し)</title>
<script type="text/javascript">
function main() {
let item_list = [
{ "id" : 1010 , "name": "みかん" , "price" : 50 } ,
{ "id" : 1020 , "name": "りんご" , "price" : 100 } ,
{ "id" : 1022 , "name": "パイナップル" , "price" : 1000 } ,
] ;
let buy_list = {
1010 : 5 , // みかん×5個
1020 : 3 , // りんご×3個
1022 : 1 , // パイナップル×1個
} ;
let sum = __________ ;
let text = "<table border='1'>" ;
// 表の属性を表示
text += "<tr>"
+ "<th>id</th>"
+ "<th>name</th>"
+ "<th>price</th>"
+ "<th>個数</th>"
+ "</tr>" ;
for( let item of __________ ) {
// item.id の購入数
let buy = __________ ;
// 行の表示
text += "<tr>"
+ "<td>"+item.id+"</td>"
+ "<td>"+item.name+"</td>"
+ "<td>"+item.price+"</td>"
+ "<td>"+___________+"</td>"
+ "</tr>" ;
// @単価 * 購入数
__________ += __________ ;
}
text += "</table>" ;
text += "合計="+sum ;
document.getElementById( "output" ).innerHTML
= text ;
}
</script>
</head>
<body onload="main()">
<h1>Sample Page 9(配列との串刺し)</h1>
<div id="output"></div>
</body>
</html>
<!-- Local Variables: -->
<!-- mode: html -->
<!-- tab-width: 8 -->
<!-- End: -->