JavaScript function to get the next date in a calendar

1

I have several calendars registered in my database, each calendar has its particularity.

I have a screen that includes a file and through dropdown I choose the calendar that the periodicity of this file will respect.

Eg Daily, Weekly, Monthly, etc.

The idea is when the user clicks on a specific textbox appears a balloon warning the next available date for the file.

Ex. Today is the 28th.

Balloon: "The next date is 04/29/2015" if the periodicity is daily.

Can you help me build this function with JavaScript?

I tried to use the code below, but my main question is how to return the next calendar date in the function

function ExibeDica(obj, msg, useBottom, maxWidth){
       try
         {
        window.status = msg;
        var msgDica = document.getElementById('msgDica');               

        if(msgDica)
        {
            msgDicaTexto.innerHTML = msg;
            msgDica.style.zIndex = 9999;
            msgDica.style.left = obj.getClientRects()[0].left + document.body.scrollLeft - 2;
            msgDica.style.display = 'block';
            if (maxWidth != null)
                if (msgDica.offsetWidth > maxWidth) msgDica.style.width = maxWidth;
            if (useBottom)
                msgDica.style.top = obj.getClientRects()[0].bottom + document.body.scrollTop;
            else
                msgDica.style.top = obj.getClientRects()[0].top + document.body.scrollTop - msgDica.offsetHeight - 4;
        }
    }
    catch(e) {} 
}

function OcultaDica(){
    try
    {
        window.status = ''; 

        var msgDica = document.getElementById('msgDica');

        if(msgDica)
        {
            msgDica.style.display = 'none';
            msgDica.style.width = null;
        }
    } 
    catch(e) {}
}
    
asked by anonymous 28.04.2015 / 19:28

1 answer

3

Check the methods of Date objects, with them you can, pick the current date, add days and / or months and use the new date. I think in your case, just take the current date and add a day, you can do it like this:

// data atual (28)   
d = new Date();  

// acrescenta um dia (29)  
d.setDate(d.getDate() + 1);

// exibe o "novo" dia (29)  
d.getDate();

You can apply the same to other rules.

    
28.04.2015 / 21:48