I'm using datepicker with the following script:
<?php print "$test_date" ?> --> returns 2014,10,25
<script>
$(function() {
$("#mydate").datepicker({
onSelect: function(dateText, inst) {
var dateAsString = dateText;
var date = $('#mydate').val();
var datex = date.replace(/[/]/g,"-"); // 01-01-2013 01:21
$('#mydatex').val(datex);
}
})
.datepicker("setDate",new Date());
//.datepicker("setDate","<?php echo $test_date; ?>"; --> this doen't work
// returns blank date
});
</script>
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>
<label>Date</label>
<input type="hidden" id="mydatex" name="mydatex"/>