javascript - datepicker values on post should not loose its behaviour -
- i using 2 datepickers in return should not less departure.
- on selecting of datepicker, executing onselect event functionality(pls check datepicker script). want make while initial load without on select. because issue return datepicker showing before date since not select departure datepicker.this issue happening when posted page, same datepickers.
eg: in first page have selected 22-12-2014 , return 30-12-2014 , if post these values page having same datepickers return can able select before 22-12-2014.
$("#departure").datepicker({ dateformat: 'dd-mm-yy', changemonth: true, changeyear: true, mindate: '+1d', numberofmonths: 2, showbuttonpanel: true, onselect: function (selecteddate) { var mindate = $(this).datepicker('getdate'); if (mindate) { mindate.setdate(mindate.getdate()); } $("#return").datepicker("option", {mindate: mindate}, selecteddate); } }); $("#return").datepicker({ dateformat: 'dd-mm-yy', changemonth: true, changeyear: true, mindate: '+1d', numberofmonths: 2, showbuttonpanel: true, onselect: function (selecteddate) { //alert($('#startpicker').val()); var mindate = $(this).datepicker('getdate'); if (mindate) { mindate.setdate(mindate.getdate()); } $("#departure").datepicker("option", {maxdate: mindate}, selecteddate); } });
you need add mindate again on new page. add like:
<?php if ($_server['request_method'] == "post") { ?> $( document ).ready(function() { $("#return").datepicker("option", {mindate: <?=$_post['departuredate']; ?>}, selecteddate); }); <?php } ?>
not tested idea.
Comments
Post a Comment