php - Dynamically update expiry date based on a previous date using JavaScript -


i want supply effective date(initial date) , system automatically add one(1) year date supplied above, using javascript or other better method.

<form action="<?php $_server['php_self'];?>" method="post">     <p>         <strong style="color:black">software name:</strong>         <input type="text" name="swname" value=""  />     </p>&nbsp;      <p>         <strong style="color:black">              company              <input type="text" name="coy" size="50" value="">         </strong>     </p>&nbsp;      <p>         <strong style="color:black">              effective date              <input type="date" name="sdate" value="" onblur="getyearval();" />         </strong>     </p>&nbsp;      <script>         function getyearval() {             //script automatically add 1 year above placed here         }     </script>      <p>             <strong style="color:black">              expiry date             <input type="date" name="edate"  id="edate"  value=""/>         </strong>          <input type="submit" name="submit" value="register " /> |          <input type="reset" name="reset" value="cancel" />   </form> 

first have create date object.

var date = new date('year','month','day');

then add 1 year:

date.setfullyear(date.getfullyear() + 1);

this example, modify according needs.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -