-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
66 lines (60 loc) · 1.85 KB
/
index.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
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lab5 - Mailer</title>
<style>
fieldset {
width: 400px;
margin: 100px auto;
display: block;
}
legend {
font-size: 24px;
}
label {
font-size: 20px;
}
input {
display: block;
margin-bottom: 20px;
}
textarea {
margin-bottom: 20px;
}
</style>
</head>
<body>
<fieldset>
<legend>Заполните форму</legend>
<form action="index.html">
<label for="input_from">FROM</label>
<input type="text" name="from" id="input_from">
<label for="input_to">TO</label>
<input type="text" name="to" id="input_to">
<label for="input_text">TEXT</label><br />
<textarea type="text" name="text" id="input_text"></textarea><br />
<input type="submit" name="submit" id="submit" value="Отправить запрос">
</form>
</fieldset>
<script>
document.querySelector("#submit").addEventListener("click", async (event) => {
event.preventDefault();
let from = document.querySelector("#input_from");
let to = document.querySelector("#input_to");
let text = document.querySelector("#input_text");
let bodyText = `{
"from": "${from.value.toString()}",
"to": "${to.value.toString()}",
"text": "${text.value.toString()}"
}`;
console.log(bodyText);
fetch("http://localhost:3000/send", {
method: "POST",
body: bodyText
});
});
</script>
</body>
</html>