Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <title>წლის გამოთვლაa</title>
- <link href="css/style.css" rel="stylesheet" type="text/css" />
- <!-- JS -->
- <script language="javascript" type="text/javascript">
- function getAge()
- {
- var birth_day, birth_month, birth_year;
- birth_day = document.getElementById("day").value;
- birth_month = document.getElementById("month").value;
- birth_year = document.getElementById("year").value;
- // calculation
- var current_date = new Date();
- var current_year = current_date.getFullYear();
- var current_month = current_date.getMonth();
- var current_day = current_date.getDate();
- var age = current_year - birth_year;
- if (current_month < (birth_month - 1)) // months start from 0 to 11
- {
- age--;
- }
- if (((birth_month - 1) == current_month) && (current_day < birth_day)) // days start from 1 to 31
- {
- age--;
- }
- // end of calculation
- document.getElementById('output').innerHTML = "თქვენ ხართ " + age + " წლის.";
- }
- </script>
- </head>
- <body>
- <div class="wrapper">
- <h1>გაიგე რამდენი წლის ხარ</h1>
- <br />
- <table class="table">
- <thead>
- <tr>
- <th>დღე</th>
- <th>თვე</th>
- <th>წელი</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>
- <input id="day" type="number" min="1" max="31" />
- </td>
- <td>
- <input id="month" type="number" min="1" max="12" />
- </td>
- <td>
- <input id="year" type="number" min="1" />
- </td>
- <td>
- <button onClick="getAge()" type="button">გამოთვლა</button>
- </td>
- </tr>
- </tbody>
- </table>
- <blockquote id="output">
- No age
- </blockquote>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment