I have an HTML date input type and I'd like to manipulate it programatically in javascript. I'm just not getting it.
I see the most commonly accepted way of manipulating the date itself is like:
var c = new Date();
c.setDate(c.getDate() + 1);
I can get the date from the input:
c = document.getElementById("date1").valueAsDate
I can set the date of the input:
document.getElementById("date2").valueAsDate = c
I can manipulate the date in c:
c.setDate(c.getDate()+1)
Using c as an interim value, I can manipulate the value of one date object with respect to the other:
c = document.getElementById("date1").valueAsDate
c.setDate(c.getDate()+1)
document.getElementById("date2").valueAsDate = c
but no amount of manipulating the elements themselves am I able to transfer the date from one object to the other without using an interim variable.
For example, although:
c = document.getElementById("date1").valueAsDate
and
document.getElementById("date2").valueAsDate = c
are both valid, they are not directly manipulatable:
document.getElementById("date1").valueAsDate
= document.getElementById("date2").valueAsDate
The above is INVALID
I seem to get close at times but I always need that interim variable.
I suppose I have 2 questions:
What am I not understanding with these values that make them non transferable (between themselves)?
What is the "cleanest" code to take the value from the document element, manipulate it by adding one day and sending it back