I have a php file that contains a bootstrap/ajax calendar with click action that open a modal bootstrap. This action send a var to the modal and when you click into submit modal button this save the var into mysql database with a php file called. My problem is that in the modal is showed the var correctly, but this isn't sended to php file to save into database.
This is my code:
$(document).ready(function() {
...
eventClick: function(event, jsEvent, view) {
$('#createEventModalEdit #start').text(event.start);
$('#createEventModalEdit #end').text(event.end);
$('#createEventModalEdit #patientName').text(event.title);
$('#createEventModalEdit #id').text(event.id);
$('#createEventModalEdit').modal('show');
...
$('#submitButtonEdit').on('click', function(e){
// We don't want this to act as a link so cancel the link action
e.preventDefault();
doSubmitEdit();
});
function doSubmitEdit(){
$("#createEventModalEdit").modal('hide');
console.log($('#apptStartTime').val());
console.log($('#apptEndTime').val());
console.log($('#apptAllDay').val());
console.log($('#id').val());
var title = $('#patientName2').val();
var start = $('#apptStartTime').val();
var end = $('#apptEndTime').val();
var allDay = $('#apptAllDay').val();
var idEvent = $('#id').val();
alert(end);
$.ajax({
url: 'process.php',
data: 'type=changetitle&title='+title+'&eventid='+idEvent, **Here var idEvent haven't value. If I change this for exist id like: '25' is changed**
type: 'POST',
dataType: 'json',
success: function(response){
if(response.status != 'success')
revertFunc();
},
error: function(e){
revertFunc();
alert('Error processing your request: '+e.responseText);
}
});
alert("form submitted");
$("#calendar").fullCalendar('renderEvent',
{
title: $('#patientName2').val(),
start: new Date($('#apptStartTime').val()),
end: new Date($('#apptEndTime').val()),
allDay: ($('#apptAllDay').val() == "true"),
},
true);
}
And html modal bootstrap code:
<div id="createEventModalEdit" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h3 id="myModalLabel1">Crear tarea</h3>
</div>
<div class="modal-body">
<form id="createAppointmentForm" class="form-horizontal">
<div class="control-group">
<label class="control-label" for="inputPatient">Tarea:</label>
<div class="controls">
<input type="text" name="patientName2" id="patientName2" tyle="margin: 0 auto;" data-provide="typeahead" data-items="4" data-source="["Value 1","Value 2","Value 3"]">
<input type="hidden" id="apptStartTime"/>
<input type="hidden" id="apptEndTime"/>
<input type="hidden" id="apptAllDay" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="start">Inicio:</label>
<div class="controls controls-row" id="start" style="margin-top:5px;">
</div>
<label class="control-label" for="end">Fin:</label>
<div class="controls controls-row" id="end" style="margin-top:5px;">
</div>
<label class="control-label" for="start">Inicio:</label>
<div class="controls controls-row" id="id" style="margin-top:5px;">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
<button type="submit" class="btn btn-primary" id="submitButtonEdit">Save</button>
</div>
What I doing bad?? How can assign correctly the value into idEvent?
Thanks!