Jump to content

[SOLVED] ADD just six months to a given date?


sayedsohail

Recommended Posts

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;

 

???

 

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;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.