Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a dropdown list that shows the number of months from 12 months upto 72 months.. when i select 12 months it should display the date calculating from current date to the specified date and year..


Suppose i select 12 months then label should display:
21 September 2012 To 21 September 2013 This is the required format of date too.

This is the code am doing now;
JavaScript
function SetDuration() {
        try {
            var month = document.getElementById("ddlContractDuration").value;
            var CurrentDate = new Date();
            var toDate = new Date();
            toDate.setMonth(Number(toDate.getMonth()) + Number(month));
            document.getElementById('txtDuration').value =toDate.toString('mm/dd/yyyy');
        }
        catch (ex) {
            alert(ex.Message());
        }
    }

but the calculation is correct but the format is not correct.
Posted
Updated 20-Sep-12 19:35pm
v2
Comments
Mohibur Rashid 20-Sep-12 23:26pm    
So far I know what you need. But we dont know why you cant do it by yourself.

First look for the solution on google. Try yourself. If you failed then show us the failed code. we will let you know how to do it.
DaveAuld 21-Sep-12 1:33am    
You are meant to use the "Improve Question" to edit and add your code in there properly formatted, not add it as a comment to the question!
Arjun Menon U.K 21-Sep-12 2:06am    
Sorry Dave

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900