SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question AS2 : Calculating Age

    Hello
    I am trying to calculate a Age of a person. I have 3 different input boxes named monthv, dayv and yearv respectively and one dynamic text box named result. I have the following code



    Code:
    on (release)
    {
    monthU=monthv-1;
    birth=new Date(yearv.text, monthv.text, dayv.text);
    today-new Date();
    age=math.floor(((((today-birth)/1000/60)/60)/24)/365);
    result.text = "you are " +age + " years old. ";
    }
    but when I click the button after entering the date of birth it show


    you are undefined years old.
    It does not calculate the age instread it shows undefined. IS my code correct? or am I missing something?

    Please help me

    Regards
    Aneel

  2. #2
    Community Advisor silver trophy

    Join Date
    Nov 2006
    Location
    UK
    Posts
    2,551
    Mentioned
    40 Post(s)
    Tagged
    1 Thread(s)
    Read back through your code for obvious errors such as having a minus where there should be an equals, defining a variable that isn't used anywhere, and trying to get a value from a textfield without using .text on the textfield name.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •