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> <p> <strong style="color:black"> company <input type="text" name="coy" size="50" value=""> </strong> </p> <p> <strong style="color:black"> effective date <input type="date" name="sdate" value="" onblur="getyearval();" /> </strong> </p> <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
Post a Comment