jdreamzer
07-08-2004, 12:06 PM
2nd post today!
I need a script that will calculate the number of calender days between two dates
The script(ideally)has a combo box for each date and then a output box for the calculation
any assistance welcome
many thanks
J
coothead
07-08-2004, 04:01 PM
Hi there jdreamzer,
Here is one that I made earlier for someone else,
it does not use combo boxes though :o
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>from today</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<style type="text/css">
/*<![CDATA[*/
body {
background:#cccccc;
}
input {
width:60px;
margin:3px;
font-family:arial;
font-size:14px;
}
#sbmt,#rst {
width:62px;
}
div#cntnt {
position:absolute;
top:20%; /*adjust this to position - y*/
left:40%; /*adjust this to position - x*/
background:#ffffff;
padding:10px;
border:double 6px #000000;
width:240px;
font-family:arial;
font-size:14px;
}
/*//]]>*/
</style>
<script type="text/javascript">
//<![CDATA[
function daysTo(year,month,day,year1,month1,day1){
for(i=0;i<6;i++){
if(isNaN(document.forms[0][2+i].value)){
alert("numbers only thankyou !");
return;
}
}
var startingdate=new Date(year,month-1,day);
var finishingdate=new Date(year1,month1-1,day1);
var today=new Date();
var one_day=1000*60*60*24;
document.forms[0][8].value=Math.floor((today.getTime()-startingdate.getTime()+(finishingdate.getTime()-today.getTime()))/(one_day));
}
//]]>
</script>
</head>
<body>
<div id="cntnt">
<form action="">
<table><tr>
<td><input type="text" readonly="readonly"value="1st date"/></td><td><input type="text" readonly="readonly"value="2nd date"/></td><td> </td>
</tr><tr>
<td><input type="text"/></td><td><input type="text"/></td><td> : year </td>
</tr><tr>
<td><input type="text"/></td><td><input type="text"/></td><td> : month </td>
</tr><tr>
<td><input type="text"/></td><td><input type="text"/> </td><td>: day </td>
</tr><tr>
<td> </td><td><input type="text"/></td><td>: no. of days </td>
</tr><tr>
<td><input id="sbmt" type="submit" value="submit"
onclick="daysTo(document.forms[0][2].value,document.forms[0][4].value,
document.forms[0][6].value,document.forms[0][3].value,
document.forms[0][5].value,document.forms[0][7].value);return false"/></td>
<td><input id="rst" type="reset"/></td><td> </td>
</tr></table>
</form>
</div>
</body>
</html>
jdreamzer
07-09-2004, 06:58 AM
beautiful coothead! Nice work. Thanks for your help
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.