Hello. Working on a calendar. Stuck on the place where you want to display the number of days depending on the month. Months are switched and the number of days remains unchanged. I do not understand how to do it. I would be very grateful for a detailed explanation. Link to the calendar (http://codepen.io/Ho4ka/pen/PpOgpe )

    1 answer 1

    Cycle

      for (var r = 0; r < totalRows; r++) { var row = document.createElement("tr"); // create cells in row for (var c = 0; c < cellsInRow; c++) { if (currentnum - start < length) { var cell = document.createElement("td"); currentnum += 1; if (start < currentnum) { var cellText = document.createTextNode(currentnum - start); cell.appendChild(cellText); cell.classList.add("days"); } row.appendChild(cell); } } tbl.appendChild(row); // add the row to the end of the table body } 

    draws the days once the page is opened and is no longer used, by clicking on the button, the code responsible for processing the display of the days is not called. You need to put it into a function that will be called when you click on a button and pass parameters to it, such as the year and month for which you want to display the days.

    • Sorry, I'm totally new. Could you write me a solution to my problem and comment on it? I understand that this is really a trifle, but so far it is hard for me. - Maksym Domaretskyi
    • In general, I explained what the problem is, if it is really incomprehensible what I am talking about, then either you did not write the code yourself, or you should start learning js from a tutorial, for example gitbook.com/book/karmazzin/eloquentjavascript_ru/details - Basilevs
    • Thanks and on this one. Probably I still have little understanding and knowledge of JS. - Maksym Domaretskyi