2014-10-09 18:54
浏览 118


I'm using datepicker with the following script:

<?php print "$test_date" ?> --> returns 2014,10,25

$(function() {

    onSelect: function(dateText, inst) {
    var dateAsString = dateText;  

    var date = $('#mydate').val();
    var datex = date.replace(/[/]/g,"-"); // 01-01-2013 01:21

     .datepicker("setDate",new Date());

     //.datepicker("setDate","<?php echo $test_date; ?>";  --> this doen't work 
     // returns blank date

the default date is set to the current date. Is there a way to dynamically set the default date with a variable passed into my form from php? i.e When I render the form I pass into it $test_date which = "2014,12,25"

and here's the top of the form:

<form name="myForm" action="createevent.php" onsubmit="return validateForm()" method="get"> 
<h1 style="color:blue;">Skipper Input Page</h1>
<div class="skipperinput"">

<input type="text" id="mydate" name="mydate" value= ""/><br>
<input type="hidden" id="mydatex" name="mydatex"/> 
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dskpywvki951583595
    dskpywvki951583595 2014-10-09 19:02
     .datepicker("setDate", new Date("<?php echo $new_default_date; ?>"));
    点赞 评论