]> Softwares of Agnibho - librevax.git/commitdiff
DOB entry by age
authorAgnibho Mondal <mondal@agnibho.com>
Thu, 11 Jan 2024 21:04:49 +0000 (02:34 +0530)
committerAgnibho Mondal <mondal@agnibho.com>
Thu, 11 Jan 2024 21:04:49 +0000 (02:34 +0530)
templates/patient-edit.html

index d9ef882de542c8000c7d39fcb9499f3dba113d3b..3a4b3979f6ef5a56c11d2c8d008c365674565a2b 100644 (file)
@@ -37,8 +37,11 @@ You should have received a copy of the GNU General Public License along with Lib
     </div>
     <div class="mb-2 row">
       <label class="form-label col-sm-3">Date of Birth</label>
-      <div class="col-sm-9">
-        <input name="dob" placeholder="YYYY-MM-DD or YYYY" pattern="\d{4}-\d{2}-\d{2}|\d{4}" required class="form-control" value="{{data["dob"]}}">
+      <div class="col-sm-8">
+        <input name="dob" id="dob" placeholder="YYYY-MM-DD or YYYY" pattern="\d{4}-\d{2}-\d{2}|\d{4}" required class="form-control" value="{{data["dob"]}}">
+      </div>
+      <div class="col-sm-1 d-grid">
+        <button type="button" id="age" class="btn btn-outline-secondary" onclick="insertByAge()">Age</button>
       </div>
     </div>
     <div class="mb-2 row">
@@ -88,4 +91,16 @@ You should have received a copy of the GNU General Public License along with Lib
     <button type="submit" class="btn btn-primary">Save</button>
   </form>
 </div>
+<script>
+  function insertByAge(){
+    age=prompt("Enter age:")
+    if(!isNaN(age)){
+      now=new Date().getFullYear()
+      document.getElementById("dob").value=(now-age)
+    }
+    else{
+      alert(age+" is not a valid number.")
+    }
+  }
+</script>
 {% endblock %}