I don't use often js script but to finish my project i need to resolve this issue. I'm using DateTimePicker from https://github.com/nehakadam/DateTimePicker .
After initialize the calendar, i can select a date and the date is showing in the calendar input. But after that i don't know how to retrieve and to send the date selected (for example 02-01-2021) to another script in further in my html file. I have a variable called :
var dataSource2 = "../testcanvas/data/Multi_band_01-01-2021.tif";
The date selected must change the dataSource2 variable (so in Multi_band_02-01-2021.tif).
Here is my code for the calendar:
<script>
$(document).ready(function()
{$("#dtBox")
.DateTimePicker({
addEventHandlers: function()
{
var dtPickerObj = this;
$("#datePicker .pickerButton").click(function(e)
{
dtPickerObj.on("change", function(e){ console.log(e.date); })
alert("test");
});
}
});
});
</script>
None of the alert and the console.log is triggered. I don't know what the problem as this stage.
Thank you very much for your help !
ok i found a solution :
<script type="text/javascript">
var oDTP, dDate, dTime, dDateTime,
sDateFormat = "";
$(document).ready(function()
{$("#dtBox")
.DateTimePicker({
dateFormat: "dd-MM-yyyy",
buttonClicked: function(sButtonType, oElement)
{
oDTP = this;
if(sButtonType === "SET")
{
datex=oDTP.getDateTimeStringInFormat("Date", "dd-MM-yyyy");
var dataSource2="../testcanvas/data/Multi_band_"+datex+".tif";
updateChart(dataSource2)
}
}
});
});
</script>
Thanks Caio Koiti for your help ! :)