How to add a month to date via javascript on load event.
The scenario is this
A dropdown box contains these option
1 Month
3 Months
6 Months
Two fields are define - StartDate, EndDate
So when a user selects from a month DropDown box that month should be added to the StartDate and the field EndDate should be updated with the new value of StartDate.
The script
var ctrlStartDate = Runner.getControl(pageid, 'StartDate');
var ctrlEndDate = Runner.getControl(pageid, 'EndDate');
var ctrlTerm = Runner.getControl(pageid, 'Term');
var currDate = ctrlStartDate;
var currDay = currDate.getDate();
var currMonth = currDate.getMonth();
var currYear = currDate.getYear();
ctrlTerm.on('change', function(e) {
if(this.getValue() =='1 Month')
{
var currMonth = currMonth + 1;
currDateStr = currMonth + "/" + currDay + "/" + currYear;
ctrlEndDate.setValue(currDateStr);
} else {
if(this.getValue() =='3 Months')
{
var currMonth = currMonth + 3;
currDateStr = currMonth + "/" + currDay + "/" + currYear;
ctrlEndDate.setValue(currDateStr);
} else {
if(this.getValue() =='6 Months')
{
var currMonth = currMonth + 6;
currDateStr = currMonth + "/" + currDay + "/" + currYear;
ctrlEndDate.setValue(currDateStr);
}
}
});
Would highly appreciate if someone could help me.
Thanks
Still waiting............ <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=18479&image=1&table=forumtopics' class='bbc_emoticon' alt=':(' />