0

Today my challenge is this: I have two inputs and a button:

Both inputs are date picker types. So When I pick a date from first input (for example I choose 11/19/2013) I want the second input to auto-complete to a one day later value. So the second one must pick 11/20/2013 automatically when I click the first input. I use these inputs to calculate a price(in my Magento store).

Below is the structure of my html (just a skeleton)

<div class="select_grid">
    <input type="text" placeholder="mm/dd/yyyy" autocomplete="off" name="from" id="from" class="hasDatepicker">
    <input type="text" placeholder="mm/dd/yyyy" autocomplete="off" name="to" id="to" class="hasDatepicker">
    <input type="submit" name="Submit">
</div>
Shatir
  • 617
  • 1
  • 5
  • 18
  • 1
    Refer to this link: http://stackoverflow.com/questions/16117718/add-a-day-with-selected-date-using-jquery-datepicker – Shatir Nov 19 '13 at 06:12

1 Answers1

0

If you're happy to use JQuery You want to set something to the onChange handler of the from field.

Something like:

onChange="$('#to').attr('value',$(this).val());"

You'll have to modify it slightly. That syntax as it stands will just copy the value across. You'll need to use the javascript or jQuery date function to increment by one day/week etc.

An example of doing this is in this overflow question: Add +1 to current date

Community
  • 1
  • 1
Joel Small
  • 187
  • 1
  • 5