-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
27 lines (23 loc) · 994 Bytes
/
script.js
File metadata and controls
27 lines (23 loc) · 994 Bytes
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
// Function to store and display selected rating
function selectRating(rating) {
const ratingValueElement = document.getElementById('rating-value');
ratingValueElement.innerText = rating;
// Highlight selected button
const buttons = document.querySelectorAll('.rating');
buttons.forEach(button => button.classList.remove('selected'));
buttons[rating - 1].classList.add('selected');
}
// Function to toggle between states
function submitRating() {
const ratingState = document.querySelector('.rating-state');
const thankYouState = document.querySelector('.thank-you');
// Ensure a rating is selected before submitting
const selectedRating = document.getElementById('rating-value').innerText;
if (selectedRating) {
// Hide rating state and show thank-you state
ratingState.style.display = 'none';
thankYouState.style.display = 'block';
} else {
alert('Please select a rating before submitting!');
}
}