Hello,
i struggle to get start time and end time from selected day in fullcalendar...pls let me know..its urgent..
below sample code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<base href="http://arshaw.com/js/fullcalendar/examples/" />
<link rel='stylesheet' type='text/css' href='../fullcalendar.css' />
<script type='text/javascript' src='../jquery/jquery.js'></script>
<script type='text/javascript' src='../jquery/jquery-ui-custom.js'></script>
<script type='text/javascript' src='../fullcalendar.min.js'></script>
<script type='text/javascript'>
var data=null;
var newwindow2=null;
var calendar=null;
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
calendar = $('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
selectable: true,
selectHelper: true,
select:pop,
/*
select: function(start, end, allDay) {
var title = prompt('Event Title:');
if (title) {
calendar.fullCalendar('renderEvent',
{
title: title,
start: start,
end: end,
allDay: allDay
},
true // make the event "stick"
);
}
calendar.fullCalendar('unselect');
},
*/
editable: true,
events: [
{
title: 'All Day Event',
start: new Date(y, m, 1)
},
{
title: 'Long Event',
start: new Date(y, m, d-5),
end: new Date(y, m, d-2)
},
{
id: 999,
title: 'Repeating Event',
start: new Date(y, m, d-3, 16, 0),
allDay: false
},
{
id: 999,
title: 'Repeating Event',
start: new Date(y, m, d+4, 16, 0),
allDay: false
},
{
title: 'Meeting',
start: new Date(y, m, d, 10, 30),
allDay: false
},
{
title: 'Lunch',
start: new Date(y, m, d, 12, 0),
end: new Date(y, m, d, 14, 0),
allDay: false
},
{
title: 'Birthday Party',
start: new Date(y, m, d+1, 19, 0),
end: new Date(y, m, d+1, 22, 30),
allDay: false
},
{
title: 'Click for Google',
start: new Date(y, m, 28),
end: new Date(y, m, 29),
url: 'http://google.com/'
}
]
});
});
function trim(s)
{
if(typeof(s)=="undefined")
return "";
return String(s).replace(/^\s+|\s+$/g,'');
}
function gatherData(f)
{
var str={};
var i=-1, limit=f.elements.length;
while( ++i < limit)
{
str[ f.elements[i].name ] = trim(f.elements[i].value);
}
data=str;
// document.getElementById("title").innerHTML=data["title"];
// document.getElementById("date").innerHTML=data["date"];
var errs=[];
if(!data.title)
errs[errs.length]="Title is required";
if(!data.start)
errs[errs.length]="Start Time is required";
if(!data.end)
errs[errs.length]="End Time is required";
if (!errs.length)
{
calendar.fullCalendar('renderEvent',
{
'title': data.title,
'start': new Date( Date.parse( data.date + " " + data.start) ),
'end': new Date( Date.parse( data.date + " " + data.end) ),
'allDay': false
},
true // make the event "stick"
);
calendar.fullCalendar('unselect');
newwindow2.close();
}
else
{
alert( "The information you submitted contains errors, specifically: \n\t" + errs.join("\n\t"));
setTimeout(function(){newwindow2.focus();},50);
}
return false;
}
function pop(s) {
newwindow2=window.open('','name','height=500,width=500');
newwindow2.onload=function(){
var strD=(s.getMonth()+1) + '/' + s.getDate() + '/'+ s.getFullYear();
newwindow2.document.getElementById("date").value=strD;
}
var tmp = newwindow2.document;
tmp.write('<html> <head> <title> popup</title> ');
tmp.write('<body> <form action ="hello.html" method="post" onsubmit="return self.opener.gatherData(this);"> ');
tmp.write('<b> Date</b> ')
tmp.write('<input type="text" id="date" name="date" readonly="readonly"> <br> ');
tmp.write('<b> Event Title</b> ')
tmp.write('<input type="text" name="title"> <br> ');
//var title = document.getElementById('title')
tmp.write('<b> Event Desc</b> ');
tmp.write('<input type="text" name="event1"> <br> ');
tmp.write('<b> start time</b> ');
tmp.write('<input type="text" name="start"> <br> ');
tmp.write('<b> end time </b> ');
tmp.write('<input type="text" name="end"> <br> ');
tmp.write('<input type="submit" name="ADD"> <br> ');
tmp.write('<input type="reset" name="CLEAR"> ');
//name = oForm.elements["title"].value;
tmp.write('</form> ')
tmp.write('</body> </html> ');
tmp.close();
}
</script>
<style type='text/css'>
body {
margin-top: 40px;
text-align: center;
font-size: 14px;
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
}
#calendar {
width: 900px;
margin: 0 auto;
}
</style>
</head>
<body>
<div id='calendar'> </div>
</body>
</html>