无法在 HTML 中创建日历链接
所有,
我在 HTML 页面的 此链接 中使用日历 PHP 源代码,但我无法获取日历。我的页面仅显示源代码(这可能意味着我没有正确链接它)。这是我的 HTML 代码:
<?php
require_once('/calendar/classes/tc_calendar.php');
?>
<html>
<head>
<title> Welcome </title>
<script language="javascript" src="calendar/calendar.js"></script>
<link href="calendar/calendar.css" rel="stylesheet" type="text/css">
</head>
<body>
....
Date:
<?php
$myCalendar = new tc_calendar("date5", true, false);
$myCalendar->setIcon("/calendar/images/iconCalendar.gif");
$myCalendar->setDate(date('d'), date('m'), date('Y'));
$myCalendar->setPath("/calendar/");
$myCalendar->setYearInterval(2000, 2015);
$myCalendar->dateAllow('2008-05-13', '2015-03-01');
$myCalendar->setDateFormat('j F Y');
$myCalendar->writeScript();
?>
</body>
</html>
是否是文件路径有问题?我在 Windows 平台上,尝试将完整路径更改为 C:\\calendar\\classes\tc_calendar.php
但它仍然不起作用。
HTML 页面显示 Date
字段之前的所有字段。我显示了 Date
字段的源代码,而不是实际的日历。
All,
I am using the calendar PHP source code at this link in my HTML page, but I am not able to get the calendar. My page simply displays the source code (which might mean I have not linked it properly). Here is the my HTML code:
<?php
require_once('/calendar/classes/tc_calendar.php');
?>
<html>
<head>
<title> Welcome </title>
<script language="javascript" src="calendar/calendar.js"></script>
<link href="calendar/calendar.css" rel="stylesheet" type="text/css">
</head>
<body>
....
Date:
<?php
$myCalendar = new tc_calendar("date5", true, false);
$myCalendar->setIcon("/calendar/images/iconCalendar.gif");
$myCalendar->setDate(date('d'), date('m'), date('Y'));
$myCalendar->setPath("/calendar/");
$myCalendar->setYearInterval(2000, 2015);
$myCalendar->dateAllow('2008-05-13', '2015-03-01');
$myCalendar->setDateFormat('j F Y');
$myCalendar->writeScript();
?>
</body>
</html>
Is it the file path that might be a problem? I am on Windows platform and I have tried changing the complete path to C:\\calendar\\classes\tc_calendar.php
and it still does not work.
The HTML pages show all the fields before the Date
field. I have the source code displayed for the Date
field and not the actual calendar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我假设表单显示在日历之前,但之后是空白的?我在你的 PHP 代码中没有看到任何明显的错误,所以它一定是 tc_calendar.php 中的错误。添加
error_reporting(-1);
以显示所有消息,并将ini_set('display_errors', 'on');
添加到脚本的最顶部以查看错误消息。I'm assuming the form shows up right before the calendar but it is blank after? I don't see anything obviously wrong in your PHP code so it must be an error in tc_calendar.php. Add
error_reporting(-1);
to show all messages andini_set('display_errors', 'on');
to the very top of your script to see the error message.尝试将 PHP 文件保存为 ANSI 而不是 Unicode。我遇到了同样的问题,目前这似乎是日历在浏览器中显示的唯一解决方案。
Try saving your PHP file as ANSI instead of Unicode. I had the same problem, and for now this seems to be the only solution for the calendar to show up in the browser.
这是一个更面向未来的解决方案:只需使用 HTML5
date
输入类型为您提供的示例
这是 1 行代码中的 10 行!当然,您应该保留当前的解决方案作为备份,以防用户使用 Firefox≤17 或 IE≤10,因为它们还不支持日期输入。
Here's a more futureproof solution: simply use the HTML5
date
input typeExample for you
That's 10 lines of code in 1! Of course, you should keep your current solution as a backup in case the user is using Firefox≤17 or IE≤10, as those don't support the date input, yet.