sayedsohail Posted October 8, 2007 Share Posted October 8, 2007 Hi everyone, I got a form with to fields, Signdate=today which is fine expire date = signdate+6months How do i achieve add six months to signdate. Please help. Quote Link to comment Share on other sites More sharing options...
sayedsohail Posted October 8, 2007 Author Share Posted October 8, 2007 This is so far i tried, but no success. Date.prototype.addMonths = function(m) { // Adds the number of months to date. this.setMonth(this.getMonth() + m); }; // number of months: var n = getElementById('howmanymonths').value; var selectdate = document.getElementById('signdate'); expiredate.addMonths(n); // set expire date : document.getElementById('expiredate').value= expiredate; Quote Link to comment Share on other sites More sharing options...
sayedsohail Posted October 8, 2007 Author Share Posted October 8, 2007 ??? Date.prototype.addMonths = function(m) { // Adds the number of months to date. // date is typed in <input type='text' id='signdate'>MM/DD/YYYY format var selectdate = document.getElementById('signdate'); selectdate.setMonth(selectdate.getMonth() + m); }; // number of months: is selected in a drop down from 1 to 24 var n = getElementById('howmanymonths').value; expiredate.addMonths(n); // set expire date in mm/dd/yy format. document.getElementById('expiredate').value= expiredate; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.