I am new to javascript, and trying to implement a javascript function to increment today's date by 1 every time next button is pressed (would also like to include a previous button as well) and would appreciate if anyone could point me in the right direction.
I have included my work so far, a bit messy at the moment it currently displays today's date in ('yyyy-mm-dd') format and then when press the "Next" Button it will increment by one, but it will only perform this procedure once.
<script type="text/javascript">
(function () {
var date = new Date(),
outputValue = document.getElementById( 'outputValue' ),
dateString = date.getFullYear().toString() + "-" + (date.getMonth() + 1) + "-" + date.getDate() ;
document.onclick = function() {
dateString = date.getFullYear().toString() + "-" + (date.getMonth() + 1) + "-" + (date.getDate()+1) ;
outputValue.innerHTML = dateString;
};
outputValue.innerHTML = dateString;
})();
</script>
<div id="outputValue"></div>
<input type="button" id="next" value="Next" />