开发者

Unable to create calendar link in HTML

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开发者_C百科 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.


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 and ini_set('display_errors', 'on'); to the very top of your script to see the error message.


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.


Here's a more futureproof solution: simply use the HTML5 date input type

Example for you


<input type="date" id="date5" min="2008-05-13" max="2015-03-01"/>

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜