Jump to content

date problem


fareedreg

Recommended Posts

You don't need AJAX to do that. You can use Javascript:

<html>
<head>
<script type="text/javascript">
function setDate(date, txt)
{
   var dates = date.split("/");
   var maxDays = 32 - new Date(dates[2], dates[0]-1, 32).getDate();
   dates[1] = parseInt(dates[1])+15;
   if (dates[1] > maxDays)
   {
      if (dates[0] == 12)
      {
         dates[0] = 1;
         dates[2] ++;
      }
      else
         dates[0] ++;
      dates[1] = dates[1]-maxDays;
   }
   txt.value = dates[0] + "/" + dates[1] + "/" + dates[2];
}
</script>
</head>

<body>
<form>
<input type="text" id="txt1" name="txt1" onblur="setDate(this.value, this.nextSibling)" /><input type="text" id="txt2" name="txt2" />
<input type="submit">
</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/188152-date-problem/#findComment-993877
Share on other sites

Thanks a lot for your support

 

You don't need AJAX to do that. You can use Javascript:

<html>
<head>
<script type="text/javascript">
function setDate(date, txt)
{
   var dates = date.split("/");
   var maxDays = 32 - new Date(dates[2], dates[0]-1, 32).getDate();
   dates[1] = parseInt(dates[1])+15;
   if (dates[1] > maxDays)
   {
      if (dates[0] == 12)
      {
         dates[0] = 1;
         dates[2] ++;
      }
      else
         dates[0] ++;
      dates[1] = dates[1]-maxDays;
   }
   txt.value = dates[0] + "/" + dates[1] + "/" + dates[2];
}
</script>
</head>

<body>
<form>
<input type="text" id="txt1" name="txt1" onblur="setDate(this.value, this.nextSibling)" /><input type="text" id="txt2" name="txt2" />
<input type="submit">
</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/188152-date-problem/#findComment-995398
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.