如何在输入数据时弹出日历
how to make the calender pop out when entering data
我试图使一个web界面,其中管理员输入客户信息,并将其存储在数据库中,但我希望日历弹出时,我点击日期字段
插入代码是这样的
<?php
function valid( $start_date, $end_date, $error)
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Insert Records</title>
</head>
<body>
<?php
if ($error != '')
{
echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
}
?>
<form action="" method="post">
<table border="1">
<tr>
<td colspan="2"><b><font color='Red'>Insert Records </font></b></td>
</tr>
<tr>
<td width="179"><b><font color='#663300'>Start Date<em>*</em></font></b></td>
<td><label>
<input type="text" name="start_date" value="<?php echo $start_date; ?>" />
</label></td>
</tr>
<tr>
<td width="179"><b><font color='#663300'>End Date<em>*</em></font></b></td>
<td><label>
<input type="text" name="end_date" value="<?php echo $end_date; ?>" />
</label></td>
</tr>
<tr align="Right">
<td colspan="2"><label>
<input type="submit" name="submit" value="Insert Records">
</label></td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
include'includes/connect.php';
if (isset($_POST['submit']))
{
$start = mysql_real_escape_string(htmlspecialchars($_POST['start_date']));
$end = mysql_real_escape_string(htmlspecialchars($_POST['end_date']));
if ($start== '' || $end == '' )
{
$error = 'Please enter the details!';
valid($start_date, $end_date, $error);
}
else
{
mysql_query("INSERT aggrement SET start_date='$start', end_date='$end'")
or die(mysql_error());
header("Location: viewaggrement.php");
}
}
else
{
valid('','','');
}
?>
您需要为每个日期输入字段添加一个id,例如id="start-date"
, id="end-date"
,然后使用jQuery UI将日期选择器绑定到输入字段。在下面的例子…
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script type="text/javascript">
$(function() {
$( "#start-date" ).datepicker();
$( "#end-date" ).datepicker();
});
</script>
在datepicker api中有更多可用的选项,但请参考文档
相关文章:
- Json在完整日历中对数据进行了编码
- JQueryUI全尺寸日历-从PHP获取JSON数据
- 将 JSON 数据绑定到日期范围选取器日历
- 为什么此 Google 日历 API 请求不返回开始时间等事件数据
- 具有完整日历的上下文菜单,在日历和上下文菜单之间传递数据
- 我有JSON数据,我想在全日历上显示
- 日历数据排序 json 树
- 在加载数据之前加载完整日历
- 在java脚本的帮助下,在日历中显示背景日期应该是红色的,我也从oracle数据库中获取数据
- 数据从PHP到JS-谷歌日历+CanvasJS
- 可以't更新完整日历中的事件数据
- 使用json解析谷歌日历数据
- 可视化数据与谷歌日历
- 如何重写jQuery日历的删除,以便我也可以删除我的数据库数据
- 谷歌日历数据阅读器在Javascript
- 完整的日历+过滤器显示的数据可能
- 寻找Javascript日历,将嵌入在一个网页,并从PHP/MySQL服务器获取数据
- 清除在完整日历中删除事件后的Post数据
- 通过servlet将数据从数据库显示到完整日历—没有列出事件
- 日历在数据JSF 2.0中