Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cannot retrieve value from the pop up calendar

Status
Not open for further replies.

puteri

Programmer
Joined
Apr 15, 2003
Messages
9
Location
MY
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()>&nbsp;
<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>&nbsp;

<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.... :)
 
How about:

var datestart = fm.start[red].value[/red];

Lee
 
thanks Lee,

ok i got it , but the function count() execute before i choose the selected date, so it will get not the latest value.
where do u think i should put the count() function ?
thanks
 
or how can i get the value from this script ?

<script language="JavaScript">

var cal1 = new calendar1(document.forms['MyForm'].elements['start']);
cal1.year_scroll = true;
cal1.time_comp = false;

</script>


i tried to print out the value which is the cal1, but it appear [object] too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top