forked from letswritetw/letswrite-customize-google-form-en
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
214 lines (190 loc) · 5.79 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Fully customizable Google Forms - Augustus - Let's Write</title>
<link rel="canonical" href="https://en.letswrite.tw/custom-google-form/">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css">
<!-- customized style -->
<style>
*, *::before, *::after {
box-sizing: border-box;
font-size: 16px;
}
html, body, .container, .row {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
.container {
max-width: 100%;
}
button {
font-size: 16px;
}
.half {
position: fixed;
margin: 0;
width: 50% !important;
height: 100%;
}
.bg {
background: url('https://picsum.photos/id/883/1920/1024/') center center;
background-size: cover;
}
.form {
left: 50%;
overflow: auto;
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}
h1, form {
width: 100%;
}
h1 {
padding-top: 16px;
text-align: center;
}
form {
margin-right: auto;
margin-left: auto;
max-width: 400px;
}
.input-group {
margin-bottom: 30px;
}
.radio-group label {
display: inline-block;
}
textarea {
min-height: 100px;
}
@media screen and (max-width: 1024px) {
.half {
position: static;
width: 100% !important;
height: auto;
}
.bg {
height: 30vh;
}
form {
padding-right: 12px;
padding-left: 12px;
}
}
</style>
<link rel="shortcut icon" href="https://letswritetw.github.io/letswritetw/dist/img/logo_512.png"/>
<!-- Google Tag Manager-->
<script>
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PGQ9WQT');
</script>
</head>
<body>
<!-- Google Tag Manager (noscript)-->
<noscript>
<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PGQ9WQT" height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>
<div class="container">
<main class="row">
<!-- bg -->
<section class="six columns half bg"></section>
<!-- form -->
<section class="six columns half form">
<h1>Contact us</h1>
<form>
<!-- name -->
<div class="input-group">
<label for="demo_name">Name</label>
<input class="u-full-width" type="text" placeholder="please enter your name" id="demo_name">
</div>
<!-- gender -->
<div class="input-group">
<label>Gender</label>
<div class="radio-group row">
<!-- male -->
<div class="four columns">
<input type="radio" id="male" name="demo_radio" value="male" checked>
<label for="male">Male</label>
</div>
<!-- female -->
<div class="four columns">
<input type="radio" id="female" name="demo_radio" value="female">
<label for="female">Female</label>
</div>
<!-- legal -->
<div class="four columns">
<input type="radio" id="legal" name="demo_radio" value="legal">
<label for="legal">Legal</label>
</div>
</div>
</div>
<!-- category -->
<div class="input-group">
<label for="demo_select">Category</label>
<select class="u-full-width" id="demo_select">
<option value="0" value="0" selected disabled>choose one</option>
<option value="cat">Cat</option>
<option value="dog">Dog</option>
<option value="bear">Bear</option>
</select>
</div>
<!-- question -->
<div class="input-group">
<label for="demo_textarea">Question</label>
<textarea class="u-full-width" id="demo_textarea"></textarea>
</div>
<button type="button" id="submit" class="button-primary u-full-width">Confirm</button>
</form>
</section>
</main>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(function() {
$('#submit').on('click', function() {
// name
var name = $('#demo_name').val() || 'no set';
// gender
var gender = function() {
var v;
$('[name="demo_radio"]').each(function() {
if($(this).prop('checked') === true) v = $(this).val();
});
return v;
};
// category
var cat = $('#demo_select').val() || 'no set';
// question
var question = $('#demo_textarea').val() || 'no set';
// post
var data = {
'entry.2065974955': name,
'entry.1310259066': gender(),
'entry.896842914': cat,
'entry.1857722787': question
};
$.ajax({
type: 'POST',
url: 'https://docs.google.com/forms/d/e/1FAIpQLScxpBiexGfPha5_vq1fos2r_9dl1QfkCJBvHWHRIbgwudOHaQ/formResponse',
data: data,
contentType: 'application/json',
dataType: 'jsonp',
complete: function() {
alert('send success');
}
});
});
});
</script>
</body>
</html>