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