// JavaScript Document
/* global variables */
var twentyNine = document.createDocumentFragment();
var thirty = document.createDocumentFragment();
var thirtyOne = document.createDocumentFragment();
/* set up node building blocks for selection list of days */
function setupDays() {
var dates = document.getElementById("delivDy").getElementsByTagName("option");
//default is 1..28, index 0..27
twentyNine.appendChild(dates[28].cloneNode(true)); // add 29th
thirty.appendChild(dates[28].cloneNode(true));
thirty.appendChild(dates[29].cloneNode(true)); // add 29th & 30th
thirtyOne.appendChild(dates[28].cloneNode(true));
thirtyOne.appendChild(dates[29].cloneNode(true));
thirtyOne.appendChild(dates[30].cloneNode(true)); // add 29th, 30th
}
function updateDays() {
var deliveryDay = document.getElementById("delivDy");
var dates = deliveryDay.getElementsByTagName("option");
var deliveryMonth = document.getElementById("delivMo");
var deliveryYear = document.getElementById("delivYr");
var selectedMonth = deliveryMonth.options[deliveryMonth.selectedIndex].value;
alert( "window month selected " + selectedMonth );
console.log("selectedMonth:" + selectedMonth);
while (dates[28]) {
// remove child with index of 28 until this index is empty
deliveryDay.removeChild(dates[28]);
}
if (deliveryYear.selectedIndex === -1) {
//if no year is selected, choose the first year
deliveryYear.selectedIndex = 0;
}
if (selectedMonth === "2" &&
deliveryYear.options[deliveryYear.selectedIndex].value === "2020") {
// if leap year, Feb has 29 days
deliveryDay.appendChild(twentyNine.cloneNode(true));
} //Thirty days have November, April, June, and September
// 4 6, 9 and 11
else if (selectedMonth === "4" || selectedMonth === "6" || selectedMonth === "9" || selectedMonth === "11") {
// these months have 30 days
deliveryDay.appendChild(thirty.cloneNode(true));
} else if (selectedMonth === "1" || selectedMonth ===...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.