hi....i still stuck with my javascript pop up calendar automatic date calculation , the process is after i choose a date(start date) from the pop calendar, the value will display inside the text box, but i need to use the value to do a calculation to get the end date, and it wil automatically display inside the end date text box.
And the main problem is i didn't get any value after i choose the date from the pop calendar for my next function which is to do the calculation. It successfully display the start date inside the start date text box, but i cannot retrive the value to do the calculation.
well this is my code:
<!-- <script language="JavaScript"> -->
<script type="text/javascript">
function count(){
var totaldur = 450;
//alert(dateend);
var fm = document.MyForm;
var datestart = fm.start;
alert (datestart); // i did'nt get this value, it keep appear [object] in the alert message box.in IE and [obejctHTMLInputElement] in Netscape 7.2
var pday2 = datestart.substring(0,2);
var pmonth2 = datestart.substring(3,5);
var pyear2 = datestart.substring(6,10);
//well this is just my calculation
//convert totaldurations (in hour) to days (ceil:rounds up a decimal number to the next largest number)
var day = totaldur / 24;
day = Math.ceil(day)
alert (day);
var now = new Date();
var dstart = new Date(pyear2 , eval(pmonth2-1) , pday2);
var end1 = new Date(dstart.getTime() + (day * 24 * 60 * 60 * 1000));
fm.schecomp.value = end1;
alert(end);
}
</script>
<form name="MyForm" method="post">
<%java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("dd-MM-yyyy");
java.util.Date currentTime_1 = new java.util.Date();
String dateString = formatter.format(currentTime_1);
%>
date start :
<input name="schestart" type="text" size="15" onblur=count()>
<a href="javascript:cal1.popup();count()"> <img src="../cal/cal.gif" width="16"
height="16" border="0"></a>
end date :
<input name="schecomp" type="text" size="15" readonly>
<script language="JavaScript">
var cal1 = new calendar1(document.forms['MyForm'].elements['start']);
cal1.year_scroll = true;
cal1.time_comp = false;
</script>
well, the code is quite messy because i still try and error to find the solutions, but the main problem is i didn't get the latest value of date start after i choose from the pop up calendar.
hope u guys out there could help me plz....
And the main problem is i didn't get any value after i choose the date from the pop calendar for my next function which is to do the calculation. It successfully display the start date inside the start date text box, but i cannot retrive the value to do the calculation.
well this is my code:
<!-- <script language="JavaScript"> -->
<script type="text/javascript">
function count(){
var totaldur = 450;
//alert(dateend);
var fm = document.MyForm;
var datestart = fm.start;
alert (datestart); // i did'nt get this value, it keep appear [object] in the alert message box.in IE and [obejctHTMLInputElement] in Netscape 7.2
var pday2 = datestart.substring(0,2);
var pmonth2 = datestart.substring(3,5);
var pyear2 = datestart.substring(6,10);
//well this is just my calculation
//convert totaldurations (in hour) to days (ceil:rounds up a decimal number to the next largest number)
var day = totaldur / 24;
day = Math.ceil(day)
alert (day);
var now = new Date();
var dstart = new Date(pyear2 , eval(pmonth2-1) , pday2);
var end1 = new Date(dstart.getTime() + (day * 24 * 60 * 60 * 1000));
fm.schecomp.value = end1;
alert(end);
}
</script>
<form name="MyForm" method="post">
<%java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("dd-MM-yyyy");
java.util.Date currentTime_1 = new java.util.Date();
String dateString = formatter.format(currentTime_1);
%>
date start :
<input name="schestart" type="text" size="15" onblur=count()>
<a href="javascript:cal1.popup();count()"> <img src="../cal/cal.gif" width="16"
height="16" border="0"></a>
end date :
<input name="schecomp" type="text" size="15" readonly>
<script language="JavaScript">
var cal1 = new calendar1(document.forms['MyForm'].elements['start']);
cal1.year_scroll = true;
cal1.time_comp = false;
</script>
well, the code is quite messy because i still try and error to find the solutions, but the main problem is i didn't get the latest value of date start after i choose from the pop up calendar.
hope u guys out there could help me plz....
