ALLOYUI Datepicker setter and getter method

I have two input text box startdate and enddate

<input type="text" id="startdate"/>
<input type="text" id="enddate"/>

I need two simple things

  1. On click of startdate and selection of start date, need to update end date with +7 days.

Format needed is mm/dd/yyyy

So if any one click startdate with 01/01/2015 i.e 1st January 2015 , than end date should automatically set with 01/08/2015

  1. On selection of startdate, I need to get enddate open automatically.

The datepicker Library I had used is ALLOYUI datepicker version 3.0 http://alloyui.com/examples/datepicker/

Can anyone please write down code please.

Guys

<script>
            var datefrom;
        YUI().use(
  'aui-datepicker',
  function(Y) {
    datefrom = new Y.DatePicker(
      {
        trigger: '#dpfrom',
        popover: {
          zIndex: 1
        },
        calendar: {
                //maximumDate : new Date(today.getFullYear(),today.getMonth()+1,today.getDate()),
                minimumDate : new Date(),
                },

        on: {
            selectionChange: function(event) {

          }
        }
      }
    );
  }
);


    //console.log(james);

    </script>

I found the may to set minimum and maximum date but still i donot have the way to set end date +7 days to current date.

Answers


Please find similar and working one for me. Please customize it if you need anything.

<input class="form-control" type="text" id="selecteddate" placeholder="Day, Mon dd, yyyy"></input>

YUI().use(
              'aui-datepicker',
              function(Y) {
                  var datepicker = new Y.DatePicker(
                  {
                    trigger: 'input',
                    popover: {
                      zIndex: 1
                    },
                    after: {
                      selectionChange: function(event) {                      
                            event.preventDefault();     
                            Y.log(datepicker.getSelectedDates());
                            var myDate=Y.DataType.Date.addDays(new Date(datepicker.getSelectedDates()),+6);                       
                            if (myDate.isValid()) {                         
                                $("#selecteddate").val(myDate);
                            }                           
                      }
                    }
                  }
                );
              }
            );


    Date.prototype.isValid = function () {
        // An invalid date object returns NaN for getTime() and NaN is the only
        // object not strictly equal to itself.
        return this.getTime() === this.getTime();
    };  

Need Your Help

Android error while creating table from parsed XML file

java android xml asynchronous xml-parsing

I'm trying to parse an XML file which contains all episodes from 1 tv show. Whenever I try to put the result from the XML file via the domparser into a List I get an error. I guess this is because it

Howto setup Apache Web Server for clustering a Web Service on two Tomcats

web-services apache axis2 tomcat7

I'm trying to setup an Apache Web Server, so that it balances requests of a client on two Tomcat servers. For the Web Service I uses Axis2. It is deployed on two Tomcats. When I invoke the Web Serv...