Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var select = document.querySelector('select');
- var list = document.querySelector('ul');
- var h1 = document.querySelector('h1');
- select.onchange = function() {
- var choice = select.value;
- // ADD CONDITIONAL HERE
- createCalendar(days, choice);
- }
- function createCalendar(days, choice) {
- list.innerHTML = '';
- h1.textContent = choice;
- for (var i = 1; i <= days; i++) {
- var listItem = document.createElement('li');
- listItem.textContent = i;
- list.appendChild(listItem);
- }
- }
- createCalendar(31,'January');
- var select = document.querySelector('select');
- var list = document.querySelector('ul');
- var h1 = document.querySelector('h1');
- select.onchange = function() {
- var choice = select.value;
- var days = 31;
- // ADD CONDITIONAL HERE
- if (choice === "April" || choice === "June" || choice === "September" || choice === "November") {
- var days = 30;
- } else if (choice === "February") {
- var days = 28;
- }
- createCalendar(days, choice);
- }
- function createCalendar(days, choice) {
- list.innerHTML = '';
- h1.textContent = choice;
- for (var i = 1; i <= days; i++) {
- var listItem = document.createElement('li');
- listItem.textContent = i;
- list.appendChild(listItem);
- }
- }
- createCalendar(31,'January');
Add Comment
Please, Sign In to add comment