Signal success to user
This commit is contained in:
+17
-6
@@ -44,6 +44,12 @@
|
|||||||
background-color: #87CEEB;
|
background-color: #87CEEB;
|
||||||
/* Change color when clicked */
|
/* Change color when clicked */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(jona) This should be specific for the sumbit-name-lable id!
|
||||||
|
label {
|
||||||
|
color: red;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@@ -55,6 +61,7 @@
|
|||||||
<input id="submit-name" type="text" placeholder="Enter your name" />
|
<input id="submit-name" type="text" placeholder="Enter your name" />
|
||||||
<button id="submit-btn" type="submit" onclick="submit">Submit</button>
|
<button id="submit-btn" type="submit" onclick="submit">Submit</button>
|
||||||
</div>
|
</div>
|
||||||
|
<label id="submit-name-label" for="submit-name">Enter Submitter Name!</label>
|
||||||
<script>
|
<script>
|
||||||
// Days of the week
|
// Days of the week
|
||||||
const daysOfWeek = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
|
const daysOfWeek = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
|
||||||
@@ -94,10 +101,11 @@
|
|||||||
|
|
||||||
const submitName = document.getElementById("submit-name")
|
const submitName = document.getElementById("submit-name")
|
||||||
const submitBtn = document.getElementById("submit-btn")
|
const submitBtn = document.getElementById("submit-btn")
|
||||||
|
const submitNameLabel = document.getElementById("submit-name-label")
|
||||||
|
|
||||||
submitBtn.onclick = function () {
|
submitBtn.onclick = function () {
|
||||||
if (submitName.value == "") {
|
if (submitName.value == "") {
|
||||||
console.log("Submitter name is missing.")
|
submitNameLabel.style.visibility = "visible"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,20 +125,23 @@
|
|||||||
},
|
},
|
||||||
body: JSON.stringify({pollId: {{ .PollId }}, username: submitName.value, choices: choices}), // Convert the data to JSON string
|
body: JSON.stringify({pollId: {{ .PollId }}, username: submitName.value, choices: choices}), // Convert the data to JSON string
|
||||||
})
|
})
|
||||||
/*
|
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error('Network response was not ok ' + response.statusText);
|
console.log(response)
|
||||||
}
|
}
|
||||||
return response.json(); // Parse the JSON response
|
|
||||||
})
|
})
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log('Success:', data); // Handle the response data
|
calendar.remove()
|
||||||
|
submitName.remove()
|
||||||
|
submitBtn.remove()
|
||||||
|
submitNameLabel.remove()
|
||||||
|
|
||||||
|
const textNode = document.createTextNode("Choices submitted. Thx.");
|
||||||
|
document.body.appendChild(textNode);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error:', error); // Handle errors
|
console.error('Error:', error); // Handle errors
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user