Thursday, 6 November 2014

Calendar Function Onclick event on Dates using Ajax and Javascript

In this tutorial  has explained about the calendar function usinh Ajax and Javascript function.Here if we click on that datys numbers according to that days and month is to be displayed in to days tabs by using Ajax and Javascript.In the javascriptwe have to written the coding as defaultView: 'agendaDay',because acyually in the id function as calendar #calendar here we have to pass the varualble as defaultDate and defaultView and dat_req are important variable this two have to write over there.In the default date the request date is to been displayed and the default view the js varialbe is 'agendaDay' have to write in that place.$_REQUEST['dates'].I hope this POst is very usefull for to develop diffferent calendar function using javascript in PHP.


Css 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;
.fc-today-button ui-button ui-state-default ui-corner-left ui-corner-right ui-state-disabled

Library Css Styles:
<link rel='stylesheet' href='jquery-ui.min.css' />
<link href='fullcalendar.css' rel='stylesheet' />
<link href='fullcalendar.print.css' rel='stylesheet' media='print' />
Download Css Files:
Library Javascript Styles:
<script src='moment.min.js'></script>
<script src='jquery.min.js'></script>
<script src='fullcalendar.min.js'></script>
Download Js Files:
<script type="text/javascript">$(document).ready(function(){var d = new Date();var n = d.getMonth(); var dt = d.getDate(); var y = d.getFullYear(); var mon = Number(n)+1;var cur_date = y+'-'+mon+'-'+dt;if(Number(dt) <= 9){ var dt1 = '0'+dt;} else{var dt1 = dt; } var dat_req = <?php echo $dates; ?>;var cur_date1 = y+'-'+mon+'-'+dt1; getJsnData(dat_req); var myArray = jQuery.parseJSON(data_result); $('#calendar').fullCalendar({theme: true,header: {left: 'prev,next',center: 'title',right: 'month,agendaWeek,agendaDay'}, defaultDate: dat_req, defaultView: 'agendaDay',editable: true,eventLimit: true, events:myArray });}); </script>

<body><div id='calendar'></div></body></html>

PHP function to Pass the Variable:

if(isset($_REQUEST['dates'])){$dates = "'".$_REQUEST['dates']."'";} else{$dates = "'".date('Y-m-d')."'";}?>

This Script Pass from JS file:

<script type="text/javascript">
var data_result = 0;
var data_result2= 0;function getJsnData(dates){}function data(dat){ var url = "nlog.php?dates="+dat;window.location=url;} </script>

No comments:

Post a Comment