Lexilou
12-11-2007, 04:50 PM
Hello all,
I am new to the boards and to JavaScript and I am hoping some of you can help me. I am trying to design a script that will calcuate the number of days between two dates. I already have the basics below but it is the actual equation that I am having problem with. Any help would be appreciated.
Here is the code I have so far.
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function dateDiff(firstmonth, firstday, firstyear, secondmonth, secondday, secondyear)
{
alert ("There are " + days + " days between the dates");
}
// End -->
</script>
</HEAD>
<BODY>
<center>
<form name=dateform>
<table>
<tr><td>
<pre>
First Date: Month: <input type=text name=firstmonth value="" size=10 maxlength=10>
Day: <input type=text name=firstday value="" size=10 maxlength=10>
Year: <input type=text name=firstyear value="" size=10 maxlength=10>
Second Date: Month: <input type=text name=secondmonth value="" size=10 maxlength=10>
Day: <input type=text name=secondday value="" size=10 maxlength=10>
Year: <input type=text name=secondyear value="" size=10 maxlength=10>
<center><input type=button value="Calculate Difference in days!"
onclick="dateDiff(firstmonth.value, firstday.value, firstyear.value, secondmonth.value,
secondday.value, secondyear.value);">
</center>
</pre>
</td></tr>
</table>
</form>
</center>
Thank you,
LL
I am new to the boards and to JavaScript and I am hoping some of you can help me. I am trying to design a script that will calcuate the number of days between two dates. I already have the basics below but it is the actual equation that I am having problem with. Any help would be appreciated.
Here is the code I have so far.
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function dateDiff(firstmonth, firstday, firstyear, secondmonth, secondday, secondyear)
{
alert ("There are " + days + " days between the dates");
}
// End -->
</script>
</HEAD>
<BODY>
<center>
<form name=dateform>
<table>
<tr><td>
<pre>
First Date: Month: <input type=text name=firstmonth value="" size=10 maxlength=10>
Day: <input type=text name=firstday value="" size=10 maxlength=10>
Year: <input type=text name=firstyear value="" size=10 maxlength=10>
Second Date: Month: <input type=text name=secondmonth value="" size=10 maxlength=10>
Day: <input type=text name=secondday value="" size=10 maxlength=10>
Year: <input type=text name=secondyear value="" size=10 maxlength=10>
<center><input type=button value="Calculate Difference in days!"
onclick="dateDiff(firstmonth.value, firstday.value, firstyear.value, secondmonth.value,
secondday.value, secondyear.value);">
</center>
</pre>
</td></tr>
</table>
</form>
</center>
Thank you,
LL