-
Notifications
You must be signed in to change notification settings - Fork 0
/
form.html
72 lines (67 loc) · 2.35 KB
/
form.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
<html>
<head>
<style>
body {background-color: LimeGreen;
font-size: 150%;}
#name {height:30px;
font-size:14pt;}
#quizName{height:30px;
font-size:14pt;}
.button {
background-color: yellow;
color: black;
font-size: 100%;}
</style>
<base target="_top">
</head>
<body>
<form id="myForm">
<legend style="font-size:18px;">(Optional) Format spreadsheet for ease of use; adds titles and color coding</legend>
<input type="button" style="background-color:OrangeRed;font-size:18px;" class="button" name="okie dokie" value="Format spreadsheet" onclick="google.script.run.formatSheet()";><br><br><br>
<legend>CREATE QUIZ:</legend>
<input type="text" name="name" id="name" placeholder="Name of form">
<input type="text" name="quizName" id="quizName" placeholder="Name of quiz (optional)">
<br><br>
<legend>Shuffle question order?</legend>
<div>
<fieldset id="ShuffleQuestion">
<input
type="radio"
id="yes"
name="shuffle"
value= "yes"
checked />
<label for="yes">Yes</label>
<input type="radio" id="no" name="shuffle" value= "no" />
<label for="no">No</label>
</fieldset>
</div>
<br>
<input type="button" class="button" value="Submit" onclick="submitData()";>
<input type="button" class="button" value="Close sidebar" onclick="google.script.host.close();">
<br>
</form>
<br><br>
<legend>NOTE: You can add alternate acceptable answers with columns C, D, E, etc. </legend>
<script>
function submitData() {
var name = document.getElementById("name").value;
var secondName = document.getElementById("quizName").value;
// var isShuffle = document.getElementById("isShuffle").value;
var isShuffle = document.querySelector('input[name="shuffle"]:checked').value;
if (secondName == "") {
secondName = name;
}
var formData = [name, secondName, isShuffle];
google.script.run.withSuccessHandler(onSuccess).withFailureHandler(onFailure).formEntry(formData);
}
function onSuccess(result) {
console.log("success");
}
function onFailure(error) {
console.log("failure");
console.log(error);
}
</script>
</body>
</html>