Code:
<html>
<head>
<title>Testing date function on 8 oct 2007</title>
<script language="Javascript" src="menu/calender/CalendarPopup.js"></script>
<script language="Javascript" src="menu/calender/AnchorPosition.js"></script>
<script language="Javascript" src="menu/calender/date.js"></script>
<script language="Javascript" src="menu/calender/PopupWindow.js"></script>
<script language="Javascript">
function calDate(downdate,podate,duration) {
//alert("You can"+downdate+"You can"+podate+"You can"+duration)
var myDate = new Date()
var result = myDate.setDate(myDate.getDate()+duration)
//var myDate = downdate
alert(result)
}
</script>
</head>
<body>
<form>
<script language="Javascript">
var cal1 = new CalendarPopup();
</script>
PO Receive Date: <input type="text" name="date2" value="" size=25>
<a href="#" onClick="cal1.select(document.forms[0].date2,'anchor2','dd-MMM-yyyy'); return false;" name="anchor2" id="anchor2">Select</a>
<br/>
Downpayment Date: <input type="text" name="date1" value="" size=25>
<a href="#" onClick="cal1.select(document.forms[0].date1,'anchor1','dd-MMM-yyyy'); return false;" name="anchor1" id="anchor1">Select</a>
<br/>
Estimate Duration: <select name="duration" onChange="calDate(document.forms[0].date1.value,document.forms[0].date2.value,document.forms[0].duration.value)">
<option value="">--
<option value="1">1
<option value="2">2
<option value="3">3
<option value="4">4
<option value="5">5
<option value="6">6
<option value="7">7
<option value="8">8
<option value="9">9
<option value="10">10
</select> Week(s)
<br/>
Estimate Completion Date: <input type="text" name="dateest" value="" size=25>
<br/>
Warranty Date: <input type="text" name="datewarranty" value="" size=25>
<br/>
Shipment Date: <input type="text" name="dateship" value="" size=25>
<a href="#" onClick="cal1.select(document.forms[0].dateship,'anchorship','dd-MMM-yyyy'); return false;" name="anchorship" id="anchorship">Select</a>
</form>
</body>
</html>
Why my javascript produce funny output to me? Can someone guide me how to calculate the advance date based on the duration from the select box? And the output should pass value in the estimate date input box and not the alert msg box.I use alert msg box for testing purpose.
Thanks.
Can someone told me how to use the code tag in this forum?
Comment