-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
78 lines (62 loc) · 2.21 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
67
68
69
70
71
72
73
74
75
76
77
78
<!doctype html>
<html>
<head>
<base target="_top">
<style>
#app {
margin: 55px auto;
width: 350px;
}
input {
width: 100%;
}
.form-group {
margin: 9px 0px 9px 0px;
}
</style>
</head>
<body>
<div id="app">
<form id="form">
<div class="form-group">
<label for="name">Имя</label>
<input type="text" name="name" placeholder="Имя" />
</div>
<div class="form-group">
<label for="number">Номер телефона</label>
<input type="text" name="number" placeholder="89600035317" />
</div>
<div class="form-group">
<input type="submit" value="Загрузить данные" />
</div>
</form>
<div id="output"></div>
</div>
<script>
//Обработка события onsubmit
let frm = document.getElementById('form');
let otp = document.getElementById('output');
if (frm.addEventListener)
frm.addEventListener('submit', submit, false);
//функция кнопки submit
function submit(event) {
event.preventDefault();
frm.style.display = 'none';
//меняем надпись
otp.innerHTML = 'Идет загрузка...';
//вызываем сервер для обработки данных формы. Функция на стороне сервера uploadFiles(form)
google.script.run.withSuccessHandler(onSuccess).withFailureHandler(onFailure).uploadFiles(this);
}
//функция по завершению работы с сервером
function onSuccess(status) {
frm.style.display = 'block'; //прячем форму
frm.reset();
otp.innerHTML = status; //показываем, что ответил сервер
}
function onFailure(e) {
frm.style.display = 'block'; //прячем форму
otp.innerHTML = JSON.stringify(e);
}
</script>
</body>
</html>