-
Notifications
You must be signed in to change notification settings - Fork 1
/
hw10.html
32 lines (30 loc) · 985 Bytes
/
hw10.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Form</title>
</head>
<body>
<form id="myForm">
<input type="text" id="name" placeholder="Name">
<input type="text" id="surname" placeholder="Surname">
<input type="number" id="age" placeholder="Age">
<button type="button" onclick="displayData()">Submit</button>
</form>
<div id="result"></div>
<script>
function displayData() {
const name = document.getElementById('name').value;
const surname = document.getElementById('surname').value;
const age = document.getElementById('age').value;
const user = {
name: name,
surname: surname,
age: age,
};
document.getElementById('result').innerHTML = JSON.stringify(user);
}
</script>
</body>
</html>