我正在尝试放置 2 个 datePickers jquery UI。错误:当我加载页面时,datePickers 没有显示。但是,如果我发布表格,它将显示它们。
这是我的代码:
<?php
//...
if ($_POST){
$dateFrom=getInput('dateFrom').' 00:00:00';
$dateTo=getInput('dateTo').' 23:59:59';
$defDate=explode('-',getInput('dateFrom'));
$defDate=$defDate[1].'/'.$defDate[2].'/'.$defDate[0];
$employeeID=getInput('employeeID');
}else{
$dateFrom=date('Y-m-d',strtotime('-1 day'));
$dateTo=date('Y-m-d').' 23:59:59';
$defDate=date('m/d/Y',strtotime('-1 day'));
$employeeID=0;
}
//================================== calendar widget ==================================
echo '<script type="text/javascript">$(function() {';
echo ' $( "#datepicker1" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
$( "#datepicker1" ).datepicker({
showWeek: true,
firstDay: 0,
changeMonth: true,
defaultDate: "'.$defDate.'",
changeYear: true,';
echo " altField: '#datepickera',altFormat: 'yy-mm-dd'});";
echo ' $( "#datepicker2" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
$( "#datepicker2" ).datepicker({
showWeek: true,
firstDay: 0,
changeMonth: true,
changeYear: true,';
echo " altField: '#datepickerb',altFormat: 'yy-mm-dd'});";
echo '});';
echo '</script>';
echo '<form action="" method="post">';
echo '<table>';
echo '<tr><td width="250">From Date<input type="text" id="datepickera" name="dateFrom" value="" /><br /><div id="datepicker1"></div></td>';
echo '<td width="250">To Date<input type="text" id="datepickerb" name="dateTo" value="" /><br /><div id="datepicker2"></div></td>';
echo '<td>'. __('Choose Employee','j-v3').':<br /><select name="employeeID" /><option value="0">--- All Employees ---</option>';
echo '</select> <input type="submit" value="Get Data" /></td>';
echo '</tr>';
echo '</table>';
echo '</form>';
//...
?>
我正在使用 jquery 1.6.2 & jquery-ui 1.8.15
请帮忙。如何始终显示 datePickers?