I have the following script on my website. The idea is that the user puts in a date, say January 1st. The script has to figure what day they actually will graduate a course. The students enter Monday, Tues, Wed, or Thurs, and then graduate on the 7th Friday. (regardless of what day they enter)
However, I need to modify it so that if the "enter date" is beyond 25 oct 2008, they graduate on the 9th Friday.
Can anyone help? I appologize, I'm just not a script type.
Thank you!
However, I need to modify it so that if the "enter date" is beyond 25 oct 2008, they graduate on the 9th Friday.
Can anyone help? I appologize, I'm just not a script type.
Thank you!
Code:
<script type="text/javascript">
<!-- Hide this code from non-JavaScript browsers
function GradDate() {
UDate=document.forms[0].entry.value; // pick up user entry
i1=UDate.indexOf('/'); // find first slash
i2=UDate.indexOf('/',i1+1); // ...second slash
UDate_M=UDate.substring(0,i1); // everything before first slash
UDate_D=UDate.substring(i1+1,i2); // ...between two slashes
UDate_Y=UDate.substring(i2+1); // ...after second slash
UDate_Y=UDate_Y*1+2000; // 2-digit year to 4-digit
UDate_M=UDate_M-1; // jan-dec=0-11
Now=new Date(UDate_Y,UDate_M,UDate_D); // convert to a date
Now_D=Now.getDay(); // sunday-saturday=0-6
Diff=47-Now_D; // seventh Friday later
Factor=24*60*60*1000; // seconds per day
Target=new Date(Now*1+Diff*Factor); // the target date
Target_M=Target.getMonth();
Target_D=Target.getDate();
Target_Y=Target.getYear();
if (Target_Y < 70) { Target_Y=Target_Y+2000; }
if (Target_Y < 1900) { Target_Y=Target_Y+1900; }
Target_M=Target_M*1+1; // Jan-Dec = 1-12
Formatted=Target_M+'-'+Target_D+'-'+Target_Y;
document.forms[0].result.value=Formatted; // display on the form
}
// End hiding -->
Comment