完整日历.链接到数据库
Fullcalendar. linking to database
目前我正在尝试使用完整的日历插件来创建日历。这是我的代码,
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='fullcalendar.css' rel='stylesheet' />
<link href='fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='moment.min.js'></script>
<script src='jquery.min.js'></script>
<script src='fullcalendar.min.js'></script>
<script>
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
selectable: true,
selectHelper: true,
select: function(start, end, jsEvent, view){
window.location = "testing.php";
},
});
});
</script>
<style>
body {
margin: 40px 10px;
padding: 0;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
font-size: 14px;
}
#calendar {
max-width: 900px;
margin: 0 auto;
}
</style>
</head>
<body>
<div id='calendar'></div>
</body>
</html>
目前,当我点击一个日期时,日历会将我重定向到test.php(这正是我想要的)。现在是棘手的部分。我如何编码它,例如,当用户在1月10日按下时,详细信息(在数据库中)将被回显到php。(testing.php).
关于我的testing.php文件应该如何完成,有什么建议吗?如果我碰巧问了一个愚蠢的问题,请提前道歉。
此外,这是一个与此类似的功能http://www.w3schools.com/php/php_ajax_database.asp提前感谢您的任何有用提示。
您可能需要在窗口中添加开始日期作为url参数。location
...
select: function(start, end, jsEvent, ){
window.location = "testing.php?start=" + start;
},
然后在php端,你会得到$_GET['start']
另一方面,您可以在select函数中发出ajax post请求。
当我从日历中选择一个日期时,我使用了一个模式来弹出,我从中提供了所需的值。
脚本
select: function (start, end, allDay) {
$('#eventTitle').val('');
$('#eventStart').val('');
$('#eventEnd').val('');
$('#eventDescription').val('');
$('#eventType').val('');
$('#eventStart').val('');
$('#eventEnd').val('');
$('#myModal').modal();
$('#eventStart').val(moment(start).format('YYYY-MM-DD, HH:mm:ss'));
$('#eventEnd').val(moment(end).format('YYYY-MM-DD, HH:mm:ss'));
HTML
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-primary">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Create Event</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="form-group"><div class="col-sm-12">
<label class="label bg-primary">Title</label> <input type="text" name="eventTitle" id="eventTitle" class="form-control" />
</div>
</div>
<div class="form-group"><div class="col-sm-12">
<label class="label bg-primary">Description</label> <textarea name="eventDescription" id="eventDescription" class="form-control" rows="5"></textarea>
</div>
</div>
<div class="form-group"><div class="col-sm-6">
<label class="label bg-primary">Event Reason</label> <select id="eventType" class="form-control" name="event_type">
<option value="">---Select One---</option>
<option value="meeting">Meeting</option>
<option value="reminder">Reminder</option>
<option value="holiday">Holiday</option>
<option value="vacation">Vacation</option>
<option value="anniversary">Anniversary</option>
<option value="unsched">Unscheduled Leave</option>
<option value="sickleave">Sick Leave</option>
</select>
</div>
</div>
<label class="label bg-primary">Event Type</label>
<div class="form-group"><div class="col-sm-6">
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default active" >
<input type="radio" id="optionsRadio" name="quality[25]" checked="checked" value="false" /> Timed
</label>
<label class="btn btn-default" >
<input type="radio" id="optionsRadio" name="quality[25]" value="true" /> All Day
</label>
</div>
</div>
</div>
<div class="col-lg-pull-2">
<div class="col-sm-6">
<div class="form-group"><label class="label bg-primary">Start Date</label>
<div class="input-group date" id="datetimepicker1" >
<input type="text" class="form-control" id="eventStart"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>
<div class="col-lg-pull-2">
<div class="col-sm-6"><input type="text" class="form-control hidden" id="eventHide"/>
<div class="form-group"><label class="label bg-primary">End Date</label>
<div class="input-group date" id="datetimepicker2">
<input type="text" class="form-control" id="eventEnd"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer"><button type="Submit" class="btn bg-primary" id="event_submit" onClick="addEvent()"><span><i class="glyphicon glyphicon-check"></i></span> Submit</button>
<button type="Reset" class="btn btn-default" data-dismiss="modal"><span><i class="glyphicon glyphicon-erase"></i></span> Close</button>
</div>
</div>
</div>
</div>
注意:以上使用Modal的代码需要引导程序插件
相关文章:
- 如何使用angularjs在iframe中嵌入来自数据库的视频链接
- angular.js从数据库中获取链接
- 将数据库中的超链接添加到查询结果
- 知道点击了什么链接添加到数据库中
- Php菜单查询数据库并显示文本/链接
- 如何设置从数据库到php会话的id点击链接
- 带有来自数据库的动态链接的花式框 href (asp.net)
- graph.facebook 获取名称和链接并发送到数据库
- 如何在数据库值达到一定数量后禁用图像链接
- 如何为数据库中的不同记录/行创建用户生成的链接列表,这些记录/行在单击时填充 html 表单
- 如何使用web2py和SQLite创建与数据库的超链接
- 从数据库中获取电子邮件值并发送(PHP电子邮件)/刷新页面,而无需更改网站链接
- jQuery动态内容链接通过php从SQL数据库加载URL,但在刷新时不会加载
- 在单击链接时运行数据库查询,但仍加载链接URL
- 链接未使用ajax/jquery从数据库加载数据
- 从文本区域或分区在数据库中插入/显示可点击链接
- 如何在文本框中显示链接,并让按钮将其保存到数据库中
- 将文本转换为动态超链接或将其存储在数据库中
- Symfony2使用数据库参数创建dynamc链接
- "取消链接"从数据库中回显结果