File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Unsure how to handle advance date calculations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Unsure how to handle advance date calculations" Watch "Unsure how to handle advance date calculations" New topic
Author

Unsure how to handle advance date calculations

vanan saravanan
Ranch Hand

Joined: Jun 02, 2006
Posts: 95
I need to come up with a leave application script. For example i have 21days of annual leave. If i select today from the drop down box and one week later in the other drop down, the script will automaticall minus 7 days out of the 21 days. I'm able to do this part. The script as follows :



<script type="text/javascript">

function checkDate(nForm){

var sDate = nForm['dc1'].value;
sDate = sDate.split('-');
sDate = new Date(sDate[2],sDate[1]-1,sDate[0])
var eDate = nForm['dc2'].value;
eDate = eDate.split('-');
eDate = new Date(eDate[2],eDate[1]-1,eDate[0])
nForm['daysApart'].value = (eDate-sDate)/86400000;
nForm['hiddenElmName'].value=nForm['daysApart'].value
alert(nForm['daysApart'].value);

return true;
}

</script>



I'm not sure how to modify the script when half days are taken. For example if i take 2.5 days of leave the script must be able calculate that there is 19.5 days of leave left. There will be 2 radio buttons, One called "Full day" the other "Half Day"


dc1 : Textbox (Date selector script)
dc2 : Textbox (Date selector script)

Server side script jsp, Mysql

Thank you so very much for your help. Greatly appreciated.
vanan saravanan
Ranch Hand

Joined: Jun 02, 2006
Posts: 95
Anyone able to help...

Your assistance is greatly appreciated.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
what is hard about it? If you detect that the half was selected do the same calculation but only remove half a day instead of a full day.

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unsure how to handle advance date calculations
 
Similar Threads
2 functions at onsubmit
Newbie need help with textfield value.
How to calculate date from two fields
floating image in firefox ? still in trouble ^_^
JSP attendance management project error