function - Calculating age in days - Javascript -


okay, have 3 text boxes. goal have fourth text box generated when user clicks button. fourth text box should populated input other 3 boxes. i've managed code here:

<html>    <head></head>    <body>       <script>          function addtextbox() {          var element = document.createelement("input");           element.setattribute("type", "text");          element.setattribute("id", "text4");          document.body.appendchild(element);           fill();          }           function fill() {          input = document.getelementbyid("text1").value + " " + document.getelementbyid("text2").value + " " + document.getelementbyid("text3").value;;;          document.getelementbyid('text4').value = input;          }        </script>       <form>          <input type="text" id="text1" value="firstname">          <input type="text" id="text2" value="lastname">          <input type="text" id="text3" value="age">          <input type="button" onclick="addtextbox()">       </form>    </body> </html> 

but there's 1 last thing need do. when user inputs age in third textbox, need have in converted age in days before appears in fourth box.

can me this?

hey can use below function calcuate no of days passing age

 function totaldays(age)     {     var = new date();     var start = new date();     start.setfullyear((now.getfullyear()-age))     var diff = - start;     var oneday = 1000 * 60 * 60 * 24;     var day = math.floor(diff / oneday);     return day ;     } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -