[英]Trying to display a javascript calendar in a php page
我一直在努力使这个工作。 我将Joomla与directphp一起使用,因此在文章中,我可以直接在文章中输入php代码。 我得到了我下载的日历(http://www.rainforestnet.com/datetimepicker/datetimepicker-tutorial.htm),但是它显示的很清晰,但是当我单击calander图像/图标时却什么也没有发生。
<head>
<script src="datetimepicker_css.js"></script>
</head>
<?php
error_reporting(E_ALL);
session_start();
echo "</BR>";
echo "</BR>";
if ($_SESSION['authman'] || $_SESSION['authhod']) {
include 'datalogin.php';
$manid1 = $_SESSION['manid'];
if (($manid1 == 113) || ($manid1 == 114)) {
$data10 = $_SESSION['views10'];
echo $data10;
echo "<form method='post'>";
echo "<label for='demo1'>Please enter a date here </label>";
echo "<input type='Text' id='demo1' maxlength='25' size='25'/>";
echo "<img src='images2/cal.gif' onclick='javascript:NewCssCal(demo1)' style='cursor:pointer'/>";
echo "</form>";
} else {
echo "You are not authorised to view this";
}
} else {
include 'ses_end.php';
header('Location: http://localhost/');
}
?>
您应该将string
发送到NewCssCal()
。
回NewCssCal('demo1')
而不是NewCssCal(demo1)
,它应该可以工作。
您是否在浏览器的javascript控制台中查看过? 我很确定有一些有用的东西(例如无法加载js脚本)。
另外:您可以编写onclick='NewCssCal(demo1);'
而不是onclick='javascript:NewCssCal(demo1)'
因为onclick
处理程序已经是javascript。
顺便说一句:写echo "<img src='images2/cal.gif' onclick='javascript:NewCssCal(demo1)' style='cursor:pointer'/>";
也是不好的风格echo "<img src='images2/cal.gif' onclick='javascript:NewCssCal(demo1)' style='cursor:pointer'/>";
最好这样:(注意报价)
echo '<img src="images2/cal.gif" onclick="NewCssCal(\'demo1\');" style="cursor:pointer"/>';
@Elliot B .: js函数显然来自选择器脚本
好的,过了一段时间之后,我仍然可以按以下方式工作,但我仍然不明白为什么其他方法无法正常工作:
<head>
<script src="datetimepicker_css.js"></script>
</head>
<?php
session_start();
if ($_SESSION['authman'] || $_SESSION['authhod']) {
include 'datalogin.php';
$manid1 = $_SESSION['manid'];
if (($manid1 == 113) || ($manid1 == 114)) {
?>
<form method="post">
<table style="width: 100%">
<tr>
<td>1st Date</td>
<td><input size="30" type="text" name="frm_1date" id="cal1"/>
<td><img src="images/cal.gif" onclick="NewCssCal('cal1');" style="cursor:pointer"/></td>
</tr>
<tr>
<td> </td>
<td><input name="Submit1" type="submit" value="submit" /></td>
</tr>
</table>
</form>
<?php
}
} else {
echo "You are not authorised to view this";
}
} else {
include 'ses_end.php';
header('Location: http://localhost/');
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.