gpt4 book ai didi

php - jQuery DatePicker - 使用 $_GET ['date' 的默认日期]

转载 作者:行者123 更新时间:2023-11-29 22:41:32 25 4
gpt4 key购买 nike

我在使用以下代码时遇到问题:

<link type="text/css" href="http://jqueryui.com/latest/themes/base/jquery.ui.all.css" rel="stylesheet" />

<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.4.2.js"></script>
<script type="text/javascript" src="http://jquery-ui.googlecode.com/svn/tags/1.8rc1/jquery-1.4.1.js"></script>
<script type="text/javascript" src="http://jquery-ui.googlecode.com/svn/tags/1.8rc1/ui/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#datepicker").datepicker({ gotoCurrent: false,
onSelect: function(date, inst) { window.location = "diary.php?date="+date; },
dateFormat: 'dd-mm-yy',
defaultDate: <?php if(isset($_GET['date'])) { echo $_GET['date']; } else { echo "null"; } ?>
});
});
</script>

出于某种原因,当我选择一个日期并切换页面时 - 它不会转到 $_GET['date'] 参数中的 defaultDate .相反,它转到某个随机页面。 defaultDate 描述说它将接受代码中设置的相同格式的字符串。

在此先感谢您的帮助。

最佳答案

我认为您缺少围绕您的值(value)的引号。

defaultDate: '<?php if(isset($_GET['date'])) { echo $_GET['date']; } else { echo "null"; } ?>'

关于php - jQuery DatePicker - 使用 $_GET ['date' 的默认日期],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2405243/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com