('#appointmentForm').submit(function(e) {
e.preventDefault();
var date = ('#date').val();
var time = ('#time').val();
var description = ('#description').val();
var appointmentHTML =
'<div class="appointment">' +
'<span class="time">' +
time +
'</span>' +
'<span class="description">' +
description +
'</span>' +
'<span class="delete">×</span>' +
'</div>';
$('[data-date="' + date + '"]').append(appointmentHTML);
var appointments = $('[data-date="' + date + '"] .appointment');
appointments.sort(function(a, b) {
var timeA = $(a).find('.time').text();
var timeB = $(b).find('.time').text();
return timeA.localeCompare(timeB);
});
$('[data-date="' + date + '"]').empty().append(appointments);
$('#appointmentForm')[0].reset();
$('#appointmentModal').css('display', 'none');
});
(document).on('click', '.appointment', function() {
var time = (this).find('.time').text();
var description = (this).closest('td').data('date');
('#time').val(time);
('#appointmentModal').css('display', 'block');
$(this).remove();
});
script.js:
(document).ready(function() {
// Get the appointment form and input fields
var appointmentForm = ('#appointmentForm');
var dateInput = ('#date');
var timeInput = ('#time');
var descriptionInput = $('#description');
// Handle form submission
$("#appointmentForm").submit(function(event) {
event.preventDefault();
// Get the form values
var date = $("#date").val();
var time = $("#time").val();
var description = $("#description").val();
alert("Appointment Details:\n\nDate: " + date + "\nTime: " + time + "\nDescription: " + description);
modal.style.display = "none";
});
});
(document).ready(function() {
var appointmentForm = ('#appointmentForm');
var dateInput = ('#date');
var timeInput = ('#time');
var descriptionInput = $('#description');
// Get the appointment details
var date = dateInput.val();
var time = timeInput.val();
var description = descriptionInput.val();
var dayCell = $('td[data-date="' + date + '"]');
var appointmentElement = $('<div class="appointment">' +
'<div class="time">' + time + '</div>' +
'<div class="description">' + description + '</div>' +
'</div>');
dayCell.append(appointmentElement);
// Reset the form inputs
dateInput.val('');
timeInput.val('');
descriptionInput.val('');
});
});
(document).ready(function() {
var appointmentForm = ('#appointmentForm');
var dateInput = ('#date');
var timeInput = ('#time');
var descriptionInput = $('#description');
form input[type="text"],
form button[type="submit"] {
display: block;
margin-top: 5px;
}
form button[type="submit"] {
margin-top: 10px;
}
make a button that allows you to delete the appointment after you make it. Change the style.css, index.html, and script.js
// Get the appointment details
var date = dateInput.val();
var time = timeInput.val();
var description = descriptionInput.val();
// Create the appointment element
var appointmentElement = $('<div class="appointment">' +
'<div class="time">' + time + '</div>' +
'<div class="description">' + description + '</div>' +
'<div class="delete">Delete</div>' +
'</div>');
// Add the appointment element to the correct day cell
var dayCell = $('td[data-date="' + date + '"]');
dayCell.append(appointmentElement);
// Reset the form inputs
dateInput.val('');
timeInput.val('');
descriptionInput.val('');
// Add a click event for the delete button
appointmentElement.find('.delete').click(function() {
$(this).parent().remove();
});