JSFiddle - React, Tailwind, and code Playground
by Marian Rick
HTML
<script src="https://raw.githubusercontent.com/dbushell/Pikaday/master/pikaday.js"></script>
<div id="result">
<b>I am the generated URL:</b> (Sorry, I do not work…)
</div>
<div id="location-1">
I am working, but I want to be synchronized with the others.
<input type="text" name="name" class="datepicker" placeholder="" id="ex1">
<input type="text" name="name" class="datepicker" placeholder="" id="ex2">
<input type="text" name="name" placeholder="">
<input type="text" name="name" placeholder="">
<input type="submit" name="submit" value="Search" />
</div>
<div id="location-2">
I am not, and I want to be syncrhonized with the first example.
<input type="text" name="name" class="datepicker" placeholder="">
<input type="text" name="name" class="datepicker" placeholder="">
<input type="text" name="name" placeholder="">
<input type="text" name="name" placeholder="">
<input type="submit" name="submit" value="Search" />
</div>
<div id="location-3">
I am not, and I want to be syncrhonized with the first example.
<input type="text" name="name" class="datepicker" placeholder="">
<input type="text" name="name" class="datepicker" placeholder="">
<input type="text" name="name" placeholder="">
<input type="text" name="name" placeholder="">
<input type="submit" name="submit" value="Search" />
</div>
CSS
html, body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
#result {
background: yellow;
}
div {
padding: 20px;
border-bottom: 1px solid red;
}
input {display: block;}
@charset"UTF-8";
/*!
* Pikaday
* Copyright © 2014 David Bushell | BSD & MIT license | http://dbushell.com/
*/
.pika-single {
z-index: 9999;
display: block;
position: relative;
color: #333;
background: #fff;
border: 1px solid #ccc;
border-bottom-color: #bbb;
font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
}
/*
clear child float (pika-lendar), using the famous micro clearfix hack
http://nicolasgallagher.com/micro-clearfix-hack/
*/
.pika-single:before, .pika-single:after {
content:" ";
display: table;
}
.pika-single:after {
clear: both
}
.pika-single {
*zoom: 1
}
.pika-single.is-hidden {
display: none;
}
.pika-single.is-bound {
position: absolute;
box-shadow: 0 5px 15px -5px rgba(0, 0, 0, .5);
}
.pika-lendar {
float: left;
width: 240px;
margin: 8px;
}
.pika-title {
position: relative;
text-align: center;
}
.pika-label {
display: inline-block;
*display: inline;
position: relative;
z-index: 9999;
overflow: hidden;
margin: 0;
padding: 5px 3px;
font-size: 14px;
line-height: 20px;
font-weight: bold;
background-color: #fff;
}
.pika-title select {
cursor: pointer;
position: absolute;
z-index: 9998;
margin: 0;
left: 0;
top: 5px;
filter: alpha(opacity=0);
opacity: 0;
}
.pika-prev, .pika-next {
display: block;
cursor: pointer;
position: relative;
outline: none;
border: 0;
padding: 0;
width: 20px;
height: 30px;
/* hide text using text-indent trick, using width value (it's enough) */
text-indent: 20px;
white-space: nowrap;
overflow: hidden;
background-color: transparent;
background-position: center center;
background-repeat: no-repeat;
...
JavaScript
// This is nothing I recommend or I do not recommend, its only to demonstrate how the picker should work. All three forms should be clickable and update the others. Submit should "generate" the URL, so that I am able to add it to a link.
// Tipp: Datepicker although got a jquery plugin on its github.
var startDate,
endDate,
updateStartDate = function () {
startPicker.setStartRange(startDate);
endPicker.setStartRange(startDate);
endPicker.setMinDate(startDate);
},
updateEndDate = function () {
startPicker.setEndRange(endDate);
startPicker.setMaxDate(endDate);
endPicker.setEndRange(endDate);
},
startPicker = new Pikaday({
showWeekNumber: true,
field: document.getElementById('ex1'),
minDate: new Date(),
//maxDate: new Date(2020, 12, 31),
onSelect: function () {
startDate = this.getDate();
updateStartDate();
}
}),
endPicker = new Pikaday({
showWeekNumber: true,
field: document.getElementById('ex2'),
minDate: new Date(),
//maxDate: new Date(2020, 12, 31),
onSelect: function () {
endDate = this.getDate();
updateEndDate();
}
}),
_startDate = startPicker.getDate(),
_endDate = endPicker.getDate();
if (_startDate) {
startDate = _startDate;
updateStartDate();
}
if (_endDate) {
endDate = _endDate;
updateEndDate();
}
var startDate,
endDate,
updateStartDate = function () {
startPicker.setStartRange(startDate);
endPicker.setStartRange(startDate);
endPicker.setMinDate(startDate);
},
updateEndDate = function () {
startPicker.setEndRange(endDate);
startPicker.setMaxDate(endDate);
endPicker.setEndRange(endDate);
},
startPicker = new Pikaday({
showWeekNumber: true,
field: document.getElementById('date_b1'),
minDate: new Date(),
onSelect: function () {
startDate = this.getDate();
updateStartDate();
}
}),
endPicker = new Pikaday({
showWeekNumber:...