I use FullCalendar.io script and I want to query into modal when clicking on dayEvent from DB MySQL filter by month value from the calendar. I have standard code FullCalendar and into the same page have Modal with DIV id="lunaTime". Need this value from DIV to $var to call a Query MySQL. Any solutions?
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: '',
right: 'title'
},
dayClick: function(start, end, jsEvent) {
lunatime = $.fullCalendar.moment(start).format('MMM');
endtime = $.fullCalendar.moment(end).format('HH:mm');
starttime = $.fullCalendar.moment(start).format('dddd, DD MMMM YYYY, HH:mm');
var mywhen = starttime + ' - ' + endtime;
var myluna = lunatime;
start = moment(start).format();
end = moment(end).format();
$('#ModalAdd #lunaTime').text(myluna);
$('#ModalAdd #startTime').val(start);
$('#ModalAdd #endTime').val(end);
$('#ModalAdd #when').text(mywhen);
$('#ModalAdd').modal('show');
}});
Into php page have <div id="lunaTime"></div>
I try AJAX:
<script>
function showUser(str) {
if (str == "") {
document.getElementById("title").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("title").innerHTML = this.responseText;
}
};
xmlhttp.open("GET","ajax.php?q="+str,true);
xmlhttp.send();
}
}
</script>
<div id="lunaTime"></div>
<div id="title"></div>
And for extract value from DIV i try this:
$(document).ready(function(){
$("#ModalAdd").on('shown.bs.modal', function(){
document.getElementById("lunaTime").onload = showUser(this.value);
alert(this.value);
});
});
Into AJAX $q value is 0, script value is 0. Where is the mistake ?