Forums

This topic is locked

Subtraction between two dates

Posted 21 Jun 2002 13:16:49
1
has voted
21 Jun 2002 13:16:49 Rian Carstens posted:
Hi

I have 3 fields in a form, "FromDate", "ToDate" and "Quantity".

I have 2 calendars on the page which allows users to easily choose the date they arrive and the date they leave.

I need the other field, "Quantity", to automaticaly be calculated. I need the calculation to work out how long the user is planning to stay.

Here is the code:

<pre id=code><font face=courier size=2 id=code>
&lt;form name="tstest" method="post"&gt;
&lt;TABLE CELLPADDING="6" CELLSPACING="0" BGCOLOR="#ffffcc" BORDER="0" width="590"&gt;
&lt;tr&gt;
&lt;td valign="top" align="left" colspan="2"&gt; &lt;font size="2" face="Verdana, Arial, Helvetica, sans-serif"&gt;Arriving
to the house
&lt;input type="Text" name="FromDate" value="50"&gt;
&lt;a href="javascript:show_calendar2('document.tstest.FromDate', document.tstest.FromDate.value);"&gt;&lt;img src="bookings/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"&gt;&lt;/a&gt;
Day - Month - Year&lt;/font&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" align="left" colspan="2"&gt; &lt;font size="2" face="Verdana, Arial, Helvetica, sans-serif"&gt;Departing
from the house
&lt;input type="Text" name="ToDate" value="100"&gt;
&lt;a href="javascript:show_calendar2('document.tstest.ToDate', document.tstest.ToDate.value);"&gt;&lt;img src="bookings/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"&gt;&lt;/a&gt;
Day - Month - Year &lt;/font&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;TR&gt;
&lt;TD VALIGN="top" align="left" colspan="2"&gt;&lt;font size="2" face="Verdana, Arial, Helvetica, sans-serif"&gt;Number
of nights calculated:
&lt;input type="text" name="Quantity" size="2" maxlength="2" value="&lt;%=sum%&gt;"&gt;
. Please check this is correct.&lt;/font&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TABLE&gt;
&lt;/form&gt; </font id=code></pre id=code>

Any help would do, thanx.

Rian

hey, I'm still learning!?!

Reply to this topic