Welcome Guest!
Please login
If you do not have an account yet on The Web Squeeze forums, please Register! It’s FREE and there are many benefits:
- Receive Fast Advice
- Learn Programming Languages
- Get Professional Website Reviews
- Quick Troubleshooting Assistance
|
|
Age Counter
This is a discussion on Age Counter, within the Javascript section. This forum and the thread "Age Counter" are both part of the Programming Your Website category.
![]() ![]() |
Jun 2 2008, 05:05 AM
Post
#1
|
|
![]() Fresh Squeezed ![]() ![]() Posts: 49 Joined: 30-March 08 From: Southern England |
What have I done wrong?
CODE <script>
// · Don't change anything here below · var age = new Date(); var day = age.getDate(); var year = age.getYear(); var month = (age.getMonth() + 1); if (year < 1000) { year += 1900; } // · Adjust values · var my_day = **2**; var my_month = **6**; var my_year = **1982**; } // · Don't change anything here below · if ((day == my_day) && (month == my_month)) { my_age = year - my_year; } else if ((day >= my_day) && (month >= my_month)) { my_age = year - my_year; } else if ((day < my_day) && (month == my_month)) { my_age = --year - my_year; } else if ((day < my_day) && (month > my_month)) { my_age = year - my_year; } else { my_age = --year - my_year; } document.write (my_age); </script> |
|
|
Jun 2 2008, 06:37 AM
Post
#2
|
|
![]() Squeeze Machine ![]() Posts: 764 Joined: 13-February 08 From: Catching the squeezed drips downunder. |
I think all the atserixes around your variable values would be your problem
CODE // · Adjust values · var my_day = **2**; var my_month = **6**; var my_year = **1982**; Should be CODE // · Adjust values ·
var my_day = 2; var my_month = 6; var my_year = 1982; -------------------- |
|
|
Jun 2 2008, 06:43 AM
Post
#3
|
|
![]() Fresh Squeezed ![]() ![]() Posts: 49 Joined: 30-March 08 From: Southern England |
Still no change.
(Rakuli did you get me email?) |
|
|
Jun 2 2008, 07:01 AM
Post
#4
|
|
![]() Squeeze Machine ![]() Posts: 764 Joined: 13-February 08 From: Catching the squeezed drips downunder. |
I didn't really look much further than the asterixes at first. What is the code supposed to do?
PS. I got your email just now (it went to junk mail folder sorry) and have replied -------------------- |
|
|
Jun 2 2008, 07:05 AM
Post
#5
|
|
|
Master of the Universe ![]() Posts: 1,298 Joined: 15-February 08 From: London, England |
Have you looked at the Firefox debugger.
Tools->Error Console Run page. -------------------- |
|
|
Jun 2 2008, 07:12 AM
Post
#6
|
|
![]() Fresh Squeezed ![]() ![]() Posts: 49 Joined: 30-March 08 From: Southern England |
It is code to change someones age yearly
|
|
|
Jun 2 2008, 07:20 AM
Post
#7
|
|
![]() Squeeze Machine ![]() Posts: 764 Joined: 13-February 08 From: Catching the squeezed drips downunder. |
You have a random stray curly brace
CODE // · Adjust values · var my_day = **2**; var my_month = **6**; var my_year = **1982**; } <---------Right here That isn't needed. (as well as getting rid of the asterixes) -------------------- |
|
|
Jun 2 2008, 07:37 AM
Post
#8
|
|
![]() Fresh Squeezed ![]() ![]() Posts: 49 Joined: 30-March 08 From: Southern England |
Sorted thank you
|
|
|
If you found The Web Squeeze to be helpful, please donate so we can keep this site FREE, FRESH, and fortified with Web Design & Development info!
![]() ![]() |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:






Jun 2 2008, 05:05 AM






