Hi Abhimanyu,

Why should this be Ajax based?  There is no need to send data to the
server in this instance as it's readily available to the client when
they enter a start date.

With jQuery (my js framework of choice) adding 7 days could be as
simple as:

$( "#ModelNameStartDate" ).change(function () {
  var enteredString = this.val();
  var stringParts= enteredString.split("/");
  var jsDate = new Date(stringParts[2], stringParts[1],
stringParts[0]);
  var endDate = jsDate.setDate(jsDate.getDate()+7); // add 7 days
  $( "#ModelNameEndDate" ).val( endDate );
});

To add months or years you would use:

var endDate = jsDate.setMonth(jsDate.getMonth()+3); // add 1 months
var endDate = jsDate.setFullYear(jsDate.getFullYear()+1); // add 1
year

Of course the above relies on the user adding a valid start date with
the correct seperators so would need a fair bit of extra work to
ensure that was the case.

I personally use jQuery and jQuery UI to add theme-able datepickers to
my date fields, which significally improves the user interface (forces
valid dates and a specific format).  If you want to know how to do
this get back in touch.

HTH, Paul

On Aug 13, 8:25 am, abhimanyu bv <[email protected]> wrote:
> hi all.
> i am having two date input forms each for start data and end date.if i
> select start date, end date should be automatically populated. i have
> wrote code for populatinf end date but how to write an onchange of
> input form for startdate,it should be ajax based.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to