Jquery UI : date picker. How to set date in date picker by $_GET
15,561
Solution 1
Use the gup function in this link to read the get parameters. Then call the setDate method (error handling omitted):
$(function() {
$("#Datepicker").datepicker();
var year = gup("year");
var day = gup("day");
var month = gup("month");
$("#Datepicker").datepicker("setDate", month + "/" + day + "/" + year);
});
Solution 2
Simple :)
set minimum date if you want for datepicker:
<?php
$today = mktime(0,0,0,$_GET['month'],$_GET['day'],$_GET['year']);
?>
<script type="text/javascript">
var thisday = new Date('<?=(date('Y/m/d', $today);?>');
$("#YOUR_INPUT").datepicker({minDate: thisday, dateFormat: 'dd/mm/yy'});
</script>
or set automatically from GET variables:
<input type="text" name="YOUR_INPUT" id="YOUR_INPUT" value="<?=$_GET['day'];?>/<?=$_GET['month'];?>/<?=$_GET['year'];?>">
I think this should solve your problem.
Solution 3
<?php
$day = $_GET['day'];
$month = $_GET['month'];
$year = $_GET['year'];
$date = "'".$day."/".$month."/".$year."'";
?>
<script>
$.datePicker("setDate", <?php echo $date; ?>);
</script>
Author by
sf_tristanb
CTO @ Y-Proximité (Lyon - France) | @sf_tristanb Symfony developper | Personal project : http://www.seek-team.com
Updated on June 16, 2022Comments
-
sf_tristanb almost 2 years
I can't find how I can set $_GET variables to set manually the date in the date picker. http://jqueryui.com/demos/datepicker/
( example : http://www.something.com/?day=21&month=2&year=2010 )
Is that possible ?
Thanks