datepicker icon indicating copy to clipboard operation
datepicker copied to clipboard

Multiple Datepickers

Open dlcohengithub opened this issue 1 year ago • 1 comments

First - nice tool, much better than the silly HTML date popup! And, I know it's old but...

I have form that has two date fields, on two different lines. If someone opens popup on one, then on the other, they overlap. So, I tweaked code a bit to close any that may be open already when another is opened. Here is what I did, followed by the affected existing code: ` .. function closeDatePickers(idOfTextBox) // dlc added // fixes problem where multiple datepickers open { var datepickers = document.getElementsByClassName('datepicker'); var textbox; var any = false; var me = false;

for(var ix=0; ix< datepickers.length; ix++) { textbox = document.getElementById(datepickers[ix].id); div = textbox.parentNode.getElementsByTagName('div'); for (jx=0;jx<div.length;jx++) { if (div[jx].getAttribute('class')=='datepickerdropdown') { textbox.parentNode.removeChild(div[jx]); if (datepickers[ix].id == idOfTextBox) me = true; any = true; } } } return me; }

// This is called when they click the icon next to the date inputbox function showDatePicker(idOfTextbox) { var textbox = document.getElementById(idOfTextbox);

if (closeDatePickers(idOfTextbox)) return false; // just closing this one /* // See if the date picker is already there, if so, remove it x = textbox.parentNode.getElementsByTagName('div'); for (i=0;i<x.length;i++) { if (x[i].getAttribute('class')=='datepickerdropdown') { textbox.parentNode.removeChild(x[i]); return false; } } */

// Grab the date, or use the current date if not valid ..`

dlcohengithub avatar Jan 30 '24 17:01 dlcohengithub

Thanks for that! Hope someone finds it useful :)

chrishulbert avatar Feb 01 '24 00:02 chrishulbert