Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sander Kvenild
DCST1007 - OOP
Commits
eaf68cfe
Commit
eaf68cfe
authored
Feb 22, 2022
by
Sander Kvenild
Browse files
Created a table that shows JSON values
parent
a2d618b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
js-ov15-oop5-sander-kvenild/index.html
0 → 100644
View file @
eaf68cfe
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Oblig 5
</title>
<style>
table
,
th
,
td
{
border
:
1px
solid
black
;
}
</style>
</head>
<body>
<h1>
Oblig 5
</h1>
<table>
<tbody
id=
"peaks"
>
<tr>
<th>
Fylke
</th>
<th>
Navn
</th>
<th>
Høyde
</th>
</tr>
</tbody>
</table>
<script
src=
"index.js"
></script>
</body>
</html>
\ No newline at end of file
js-ov15-oop5-sander-kvenild/index.js
0 → 100644
View file @
eaf68cfe
let
peaks
=
document
.
getElementById
(
"
peaks
"
);
fetch
(
'
fylkestopper.json
'
)
.
then
(
response
=>
response
.
json
())
.
then
(
json
=>
{
for
(
const
peak
of
json
)
{
let
fylke
=
document
.
createElement
(
'
td
'
);
fylke
.
innerText
=
peak
.
fylke
;
let
navn
=
document
.
createElement
(
'
td
'
);
navn
.
innerText
=
peak
.
navn
;
let
height
=
document
.
createElement
(
'
td
'
);
height
.
innerText
=
`
${
peak
.
høyde
}
m`
;
let
row
=
document
.
createElement
(
'
tr
'
);
row
.
appendChild
(
fylke
);
row
.
appendChild
(
navn
);
row
.
appendChild
(
height
);
peaks
.
appendChild
(
row
);
}
});
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment