javascript - How to send var from ajax to submit of modal in bootstrap? -
i have php file contains bootstrap/ajax calendar click action open modal bootstrap. action send var modal , when click submit modal button save var mysql database php file called. problem in modal showed var correctly, isn't sended php file save database.
this 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){ // don't want act link cancel 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 change exist id like: '25' changed** type: 'post', datatype: 'json', success: function(response){ if(response.status != 'success') revertfunc(); }, error: function(e){ revertfunc(); alert('error processing 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 doing bad?? how can assign correctly value idevent?
thanks!
Comments
Post a Comment