-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
83 lines (67 loc) · 2.62 KB
/
Copy pathscript.js
File metadata and controls
83 lines (67 loc) · 2.62 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
function addData() {
// Get input of user name and meeting name
let name = document.getElementById('nameInput').value
const meetingName = document.querySelector('#userMeetingInput')
meetingName.innerHTML =
'Meeting name:' +
document.getElementById('meetingInput').value.toUpperCase()
// Get input values for specific date
if (document.getElementById('nineInput').checked) {
nineInput = document.getElementById('nineInput').value
} else {
nineInput = document.getElementById('nineInputHidden').value
}
if (document.getElementById('tenInput').checked) {
tenInput = document.getElementById('tenInput').value
} else {
tenInput = document.getElementById('tenInputHidden').value
}
if (document.getElementById('elevenInput').checked) {
elevenInput = document.getElementById('elevenInput').value
} else {
elevenInput = document.getElementById('elevenInputHidden').value
}
// Get the table and insert a new row at the end
let table = document.getElementById('outputTable')
let newRow = table.insertRow(table.rows.length)
// Insert data into cells of new row
newRow.insertCell(0).innerHTML = selectedDayElement.textContent
newRow.insertCell(1).innerHTML = name
newRow.insertCell(2).innerHTML = nineInput
newRow.insertCell(3).innerHTML = tenInput
newRow.insertCell(4).innerHTML = elevenInput
}
// Get a reference to the table body and selectedDayElement
const calendarBody = document.querySelector('#calendar tbody')
const selectedDayElement = document.querySelector('#selectedDay')
// Function to generate the calendar for the current month
function generateCalendar(year, month) {
calendarBody.innerHTML = ''
const firstDay = new Date(year, month, 1)
const lastDay = new Date(year, month + 1, 0)
let currentDate = new Date(firstDay)
while (currentDate <= lastDay) {
const cell = document.createElement('td')
cell.textContent = currentDate.getDate()
// Add a click event listener to record the selected day
cell.addEventListener('click', function () {
const clickedDate = new Date(
year,
month,
parseInt(event.target.textContent)
)
selectedDayElement.textContent = `${clickedDate.toDateString()}`
})
// Add the cell to the calendar
calendarBody.appendChild(cell)
// Move to the next day
currentDate.setDate(currentDate.getDate() + 1)
// Start a new row at the beginning of the week
if (currentDate.getDay() === 0) {
const newRow = document.createElement('tr')
calendarBody.appendChild(newRow)
}
}
}
// Initial load
generateCalendar(2023, 8) // September is month 8 (0-based index)