Java Reference
In-Depth Information
var firstYear =
myForm.firstYear.options[myForm.firstYear.selectedIndex].value;
var secondYear =
myForm.secondYear.options[myForm.secondYear.selectedIndex].value;
var firstDate = new Date(firstDay + “ “ + firstMonth + “ “ + firstYear);
var secondDate = new Date(secondDay + “ “ + secondMonth + “ “ +
secondYear);
var daysDiff = (secondDate.valueOf() - firstDate.valueOf());
daysDiff = Math.floor(Math.abs((((daysDiff / 1000) / 60) / 60) / 24));
myForm.txtDays.value = daysDiff;
}
function window_onload()
{
var theForm = document.form1;
var nowDate = new Date();
theForm.firstDay.options[nowDate.getDate() - 1].selected = true;
theForm.secondDay.options[nowDate.getDate() - 1].selected = true;
theForm.firstMonth.options[nowDate.getMonth()].selected = true;
theForm.secondMonth.options[nowDate.getMonth()].selected = true;
theForm.firstYear.options[nowDate.getFullYear() - 1970].selected = true;
theForm.secondYear.options[nowDate.getFullYear() - 1970].selected = true;
}
</script>
</head>
<body onload=”window_onload()“>
<form action=”“ name=”form1”>
<p>
First Date<br />
<select name=”firstDay” onchange=”recalcDateDiff()“>
<script type=”text/javascript”>
writeOptions(1, 31);
</script>
</select>
<select name=”firstMonth” onchange=”recalcDateDiff()“>
<script type=”text/javascript”>
writeMonthOptions();
</script>
</select>
<select name=”firstYear” onchange=”recalcDateDiff()“>
<script type=”text/javascript”>
writeOptions(1970, 2020);
</script>
</select>
</p>
<p>
Second Date<br />
<select name=”secondDay” onchange=”recalcDateDiff()“>
<script type=”text/javascript”>
writeOptions(1, 31);
</script>
</select>
<select name=”secondMonth” onchange=”recalcDateDiff()“>
<script type=”text/javascript”>
writeMonthOptions();
</script>
</select>
Search WWH ::




Custom Search