Link to home
Start Free TrialLog in
Avatar of thunderchicken
thunderchicken

asked on

I need some dates

Ha ha, you thought I was a despirate fat man looking for a lover.  

This is pretty easy, I just don't feel like looking this stuff up and implementing it.  So here's bunch of points for a cut and paste answer.

With the following HTML, I need a javascript that will add a week to each date.  For example if I enter in today's date into txtThisDate, it will automatically populate txtID1 to 7/25/02, txtID2 to 8/1/02, txtID3 to 8/8/02 and txtID4 to 8/15/02.  They will be able to change the txtID(n).  I'm assuming the txtThisDate will be an onBlur() command.

Code sample:

self.asp
--------

...
<script language="javascript" src="/include/signup_checkForm.js"></script>
<script language="javascript" src="/include/erythro.js"></script>
...

...
<form method="post" action="self.asp" name="frmE" onSubmit="validateform(frmE)">
<input TYPE="text" SIZE="9" name="txtThisDate" onBlur="isDate(this,'This Date')" value="MM/DD/YYYY">
<input TYPE="text" SIZE="9" onBlur="isDate(this,'1 Injection Date')" name="txtID1">
<input TYPE="text" SIZE="9" onBlur="isDate(this,'2 Injection Date')" name="txtID2">
<input TYPE="text" SIZE="9" onBlur="isDate(this,'3 Injection Date')" name="txtID3">
<input TYPE="text" SIZE="9" onBlur="isDate(this,'4 Injection Date')" name="txtID4">
<input type = submit>
</form>
...

erythro.js
----------

function validateform(form)
{    
     if (form.ThisDate.value == ""){
          alert("Enter a date");
          form.txtName.focus();
     return false
     }    
  form.submit();
}

signup_checkForm.js
-------------------
function chkdate(objName) {
   //all this does is validate the date and change it to a proper format
}

ASKER CERTIFIED SOLUTION
Avatar of bobbit31
bobbit31
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thunderchicken
thunderchicken

ASKER

I'm getting a syntax error...

document.frmE.txtID1.value =  DayAdd((intMonth + "/" + intday + "/" + strYear), 7);
       
Like this..

 document.frmE.txtID1.value =  DayAdd("12/12/2002", 7);
       

it says object doesn't support this method or property.

but i can do this

 document.frmE.txtID1.value =  intMonth;
       
try:

document.frmE.txtID1.value = DayAdd(new Date(intMonth + "/" + intDay + "/" + strYear),7));
That worked, however, how do I format it to MM/DD/YYYY Format.  this is all i need left and the points are yours
function formatDateShortFormat(d) {
     return d.getDay() + "/" + d.getMonth() + "/" + d.getFullYear();
}

just pass the result of DayAdd to the above function
getDay returns the Sunday Monday Tues value, it's getDate() FYI, but it works, thanks
welcome, thanks for so many points ;)
No, thank you from keeping me from looking up this stuff and being creative when it's so close to the weekend.  He he