Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

HELP ME PLZ: CalculateAge problem..

Javascript coding ..

Moderators: macek, egami, gesf

HELP ME PLZ: CalculateAge problem..

Postby moon » Sat Jun 25, 2011 11:19 pm

function CalculateAge()
{
if(document.form1.dob.value=="")
{
document.getElementById('age').value = 0;
}
else
{
var dob = document.form1.dob.value.split( '-' );
var dateCurrent = new Date();
var dateCurrentYear = dateCurrent.getFullYear();
var dateCurrentMonth = dateCurrent.getMonth();
var dateCurrentDay = dateCurrent.getDay();
var year = dateCurrentYear - parseInt(dob[2]);
//var month = dateCurrentMonth - parseInt(dob[1]);
//var day = dateCurrentDay - parseInt(dob[0]);
var age= year;
document.getElementById('age').value = age; //output just in year..

}
}


i just want to get the age in year, month, day..could anyone help me to solve this problem??... :(
example : 1 year 6 month 2 day..

pls..pls..pls..help me..im junior only ... :(
moon
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sat Jun 25, 2011 11:11 pm

Re: HELP ME PLZ: CalculateAge problem..

Postby lokanath7 » Mon Aug 29, 2011 7:42 am

refer to this site... u ll find ur answer...enjoy


http://snippets.dzone.com/posts/show/623
lokanath7
New php-forum User
New php-forum User
 
Posts: 139
Joined: Mon Nov 15, 2010 12:11 am


Return to JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron