Date Moves By Days

[Total: 0    Average: 0/5]

This script shows how to have a date in a form box that can be changed by day.

Body Code:

<script>
var _D = new Date(); /* current date - could be set to start at any specific date */
var _d = 1000 * 60 * 60 * 24; /* amount to change date */
function moveDate(_v)
{
  if(_v)
  {
    _D.setTime(_D.getTime() - _d);
  }
  else
  {
    _D.setTime(_D.getTime() + _d);
  }
  document.mydate.thedate.value=showDate(_D);
}
function showDate(_day)
{
  var _return ="";
      _return+=_day.getMonth();
	  _return+="/"+_day.getDate();
	  _return+="/"+_day.getYear();
  return(_return);
}
var _F ='';
    _F+='<form name=mydate>';
    _F+='<input type=button name=b1 onclick=moveDate(true) value="<">';
    _F+='<input type=text name=thedate value="'+showDate(_D)+'">';
    _F+='<input type=button name=b2 onclick=moveDate(false) value=">">';
    _F+='</form>';
document.write(_F); /* show the form with the date in it */
</script>

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *