Как сделать календарь с редактируемыми событиями (пользователи не могут получить доступ)CSS

Разбираемся в CSS
Ответить Пред. темаСлед. тема
Anonymous
 Как сделать календарь с редактируемыми событиями (пользователи не могут получить доступ)

Сообщение Anonymous »

Я работаю над проектом, где я хочу включить календарь с предстоящими событиями и мероприятиями. Я смог найти какой -нибудь код для базового календаря, но я не могу понять, как добавить события в определенные дни. < /P>
Вот мой код в настоящее время. Он работает, как и ожидалось, и я могу переехать из месяца в месяц, но я не уверен, как я могу добавить события в определенные дни (это должны быть в те же дни каждый месяц). Я рассматривал возможность использовать цикл Foreach, но я не уверен, как реализовать < /p>
html: < /p>
`






chevron_left


chevron_right



  • Sun
  • Mon
  • Tue
  • Wed
  • Thu
  • Fri
  • Sat




    Javascript:
    let date = new Date();
    let year = date.getFullYear();
    let month = date.getMonth();

    const day = document.querySelector(".calendar-dates");

    const currdate = document.querySelector(".calendar-current-date");

    const prenexIcons = document.querySelectorAll(".calendar-navigation span");

    // Array of month names
    const months = [
    "January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July",
    "August",
    "September",
    "October",
    "November",
    "December",
    ];

    // Function to generate the calendar
    const manipulate = () => {
    // Get the first day of the month
    let dayone = new Date(year, month, 1).getDay();

    // Get the last date of the month
    let lastdate = new Date(year, month + 1, 0).getDate();

    // Get the day of the last date of the month
    let dayend = new Date(year, month, lastdate).getDay();

    // Get the last date of the previous month
    let monthlastdate = new Date(year, month, 0).getDate();

    // Variable to store the generated calendar HTML
    let lit = "";

    // Loop to add the last dates of the previous month
    for (let i = dayone; i > 0; i--) {
    lit += `[*]${monthlastdate - i + 1}`;
    }

    // Loop to add the dates of the current month
    for (let i = 1; i {
    // When an icon is clicked
    icon.addEventListener("click", () => {
    // Check if the icon is "calendar-prev"
    // or "calendar-next"
    month = icon.id === "calendar-prev" ? month - 1 : month + 1;

    // Check if the month is out of range
    if (month < 0 || month > 11) {
    // Set the date to the first day of the
    // month with the new year
    date = new Date(year, month, new Date().getDate());

    // Set the year to the new year
    year = date.getFullYear();

    // Set the month to the new month
    month = date.getMonth();
    } else {
    // Set the date to the current date
    date = new Date();
    }

    // Call the manipulate function to
    // update the calendar display
    manipulate();
    });
    });



    Подробнее здесь: https://stackoverflow.com/questions/795 ... ant-access
    Реклама
    Ответить Пред. темаСлед. тема

    Быстрый ответ

    Изменение регистра текста: 
    Смайлики
    :) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
    Ещё смайлики…
       
    К этому ответу прикреплено по крайней мере одно вложение.

    Если вы не хотите добавлять вложения, оставьте поля пустыми.

    Максимально разрешённый размер вложения: 15 МБ.

    • Похожие темы
      Ответы
      Просмотры
      Последнее сообщение

    Вернуться в «CSS»