{"id":75,"date":"2009-06-01T14:31:55","date_gmt":"2009-06-01T09:01:55","guid":{"rendered":"http:\/\/vikku.info\/codesnippets\/?p=75"},"modified":"2009-07-08T02:34:14","modified_gmt":"2009-07-07T21:04:14","slug":"find-age-using-javascript","status":"publish","type":"post","link":"http:\/\/vikku.info\/codesnippets\/javascript\/find-age-using-javascript\/","title":{"rendered":"find age using javascript"},"content":{"rendered":"<pre lang=\"javascript\">\r\n\r\n\r\n<script language=\"javascript\">\r\n\r\nfunction Age()\r\n{\r\nvar bday=parseInt(document.forms[0].txtBday.value);\r\nvar bmo=(parseInt(document.forms[0].txtBmo.value)-1);\r\nvar byr=parseInt(document.forms[0].txtByr.value);\r\nvar byr;\r\nvar age;\r\nvar now = new Date();\r\ntday=now.getDate();\r\ntmo=(now.getMonth());\r\ntyr=(now.getFullYear());\r\n\r\n{\r\nif((tmo > bmo)||(tmo==bmo & tday>=bday))\r\n{age=byr}\r\n\r\nelse\r\n{age=byr+1}\r\nalert(\"As of today, \"+now+' \\n'+\", you are:\"+(tyr-age)+ \" years old\");\r\n}}\r\n\r\n<\/script>\r\n\r\n<\/pre>\n<p>here is the form<\/p>\n<pre lang=\"html4strict\">\r\n\r\n<form><center>\r\nEnter your birthday&nbsp;&nbsp;<input type=\"text\" name=\"txtBday\" size=\"2\"><br\/>\r\nEnter your birth Month(1-12)<input type=\"text\" name=\"txtBmo\"size=\"2\"><br\/>\r\nEnter your 4 digit birth year<input type=\"text\" name=\"txtByr\"size=\"4\" ><br\/>\r\n<input type=\"button\" value=\"submit\" onClick=\"alert('er');Age()\">\r\n<br\/><input type=\"reset\" value=\"reset\"><\/center>\r\n<\/form>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>here is the form Enter your birthday&nbsp;&nbsp; Enter your birth Month(1-12) Enter your 4 digit birth year<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"http:\/\/vikku.info\/codesnippets\/wp-json\/wp\/v2\/posts\/75"}],"collection":[{"href":"http:\/\/vikku.info\/codesnippets\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/vikku.info\/codesnippets\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/vikku.info\/codesnippets\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/vikku.info\/codesnippets\/wp-json\/wp\/v2\/comments?post=75"}],"version-history":[{"count":16,"href":"http:\/\/vikku.info\/codesnippets\/wp-json\/wp\/v2\/posts\/75\/revisions"}],"predecessor-version":[{"id":134,"href":"http:\/\/vikku.info\/codesnippets\/wp-json\/wp\/v2\/posts\/75\/revisions\/134"}],"wp:attachment":[{"href":"http:\/\/vikku.info\/codesnippets\/wp-json\/wp\/v2\/media?parent=75"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/vikku.info\/codesnippets\/wp-json\/wp\/v2\/categories?post=75"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/vikku.info\/codesnippets\/wp-json\/wp\/v2\/tags?post=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}