javascript - set the current date as the default early in my datepicker so that I can filter the data according to the current date -
i have daterangepicker here can see javascrpt , css in: http://jsfiddle.net/cumfw/
i have try show set default date solution(jquery-ui datepicker default date & how pre-populate jquery datepicker textbox today's date?) still not work.
this partially experiment php code:
<script type="text/javascript" src="js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="js/jquery-ui-1.7.1.custom.min.js"></script> <link rel="stylesheet" href="css/ui.daterangepicker.css" type="text/css" /> <link rel="stylesheet" href="css/redmond/jquery-ui-1.7.1.custom.css" type="text/css"title="ui-theme" /> <script type="text/javascript"> $(function(){ $('#tgl').daterangepicker({ defaultdate: new date(), arrows:true, onchange: function(){ $('#frmdate').submit() }, }); }); </script> <?php $dates = explode("-",$_post[tgl] ); $date1= date("y-m-d", strtotime($dates[0])); if ($dates[0] == $_post[tgl]){ $date2 = $date1; echo $date2; } else{ $date2= date("y-m-d", strtotime($dates[1]));} ?> <form id="frmdate" action="http://localhost/job/uadmin.php?page=absensi" method="post"> <input id="tgl" name="tgl" type="text" class="field" value="<?php echo $_post[tgl]; ?>"/> </form>
please me out problem thanks.
two things i'd try. first, make sure have link jquery above script block. use either google's or local copy:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
if doesn't work, next try replacing instances of $
in javascript code jquery
:
jquery(function(){ jquery('#tgl').daterangepicker({ defaultdate: new date(), arrows:true, onchange: function(){ jquery('#frmdate').submit() }, }); });
this can avoid conflicts other libraries use $
variable.
Comments
Post a Comment