| | |
Unsure how to handle advance date calculations
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2006
Posts: 15
Reputation:
Solved Threads: 0
I need to come up with a leave application script. For example i have 21days of annual leave. The actual amount will be taken from a database. 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 find the script for this. 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. I'm a total newbie. Greatly appreciated.
<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. I'm a total newbie. Greatly appreciated.
![]() |
Similar Threads
- Collins: Why this scientist believes in God (Geeks' Lounge)
- date (C++)
- DaniWeb New York Get Together (Geeks' Lounge)
- Microsoft Access date validation Need a solution (Computer Science)
- need date validation help (MS Access and FileMaker Pro)
- Microsoft Access date validation Need a solution (Database Design)
- mock test question, can anyone help (C)
- Zend PHP Certification (PHP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Javascript Help
- Next Thread: List Box as input field also
Views: 1702 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
acid2 ajax ajaxcode ajaxhelp animate array automatically autoplay beta boarder box bug button calendar captcha card cart codes column cookies createrange() css cursor date debugger decimal design developer dom download dropdown element enter error events firefox firehose flash focus form frameworks getselection google gwt html htmlform iframe image() index java javascript javascripts jawascriptruntimeerror jquery jsp listbox maps marquee masterpage menu microsoft mimic mp3 mp4 offline onmouseover parameters php player post problem programming progressbar prototype rating redirect regex safari scale scriptlets search select size sources sql starrating text textarea toggle twitter validation variables w3c web website window windowofwords windowsxp xml xspf





