-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
53 lines (45 loc) · 2.05 KB
/
Copy pathindex.js
File metadata and controls
53 lines (45 loc) · 2.05 KB
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
let currentQuestion = 1;
function nextQuestion() {
document.getElementById(`question${currentQuestion}`).classList.remove('active');
currentQuestion++;
if (currentQuestion > 5) {
window.location.href = 'main.html'; // Replace with the actual path to the second page
} else {
document.getElementById(`question${currentQuestion}`).classList.add('active');
}
}
function addComment() {
var commentInput = document.getElementById('commentInput');
var commentText = commentInput.value;
var commentsContainer = document.getElementById('commentsContainer');
var nameText = "User"; // Replace this with the actual user name, if available.
if (commentText !== '') {
// Create a new comment element
const newComment = document.createElement('div');
newComment.className = 'comment';
newComment.innerHTML = `
<img src="img/dudee.jpg" alt="User Image" width="50" height="50">
<p><strong>${nameText}:</strong> ${commentText}</p>
<div class="comment-info">
<span class="comment-time">Just now</span>
<span>·</span>
<span>Like</span>
<span>·</span>
<span>Reply</span>
</div>
`;
// Append the new comment to the comments container
commentsContainer.appendChild(newComment);
// Clear the input and replace with "Comment Added!"
commentInput.value = 'Comment Added!';
// Optionally, you can disable the textarea temporarily if needed
commentInput.disabled = true;
// Re-enable and clear the textarea after a brief period (optional)
setTimeout(function() {
commentInput.value = '';
commentInput.disabled = false;
}, 2000); // Change 2000 to the desired delay (in milliseconds)
} else {
alert('Please enter a comment.');
}
}