ajax - fullcalendar dayclick mysqli php -


so have jquery (fullcalendar) , showing records through database query. fine until here :)

now want add event when person clicks on date (only start(date) required) person must choose combobox (and combobox populate through database too) title.

from understanding have ajax(?) don't know how because don't know ajax..

i have in fullcalendar:

dayclick: function(date, allday, jsevent, view) {             if (allday) {                        alert('clicked on entire day: ' + date);             }else{                 alert('clicked on slot: ' + date);             }         } 

so assume have call ajax function after "if (allday){" , prepare php file query, don't know how can put select option in there.. after selection when user click add run script add database..

the combobox database query have title. calendar shows month(all days month).

sorry if english bad!

you can open dialog on dayclick event (http://api.jqueryui.com/dialog/, note: not included in fullcalendar jqueryui source file). add combobox / select dialog. data ajax / json (http://api.jquery.com/jquery.getjson/).

add button dialog , add event (http://arshaw.com/fullcalendar/docs/event_data/addeventsource/) via function.

useful questions manipulation select:

note source contains examples. fullcalendar-1.6.1/demos/selectable.html seems useful solve question.

i create demo page using: http://arshaw.com/fullcalendar/docs/usage/

calendar.html:

<html> <head> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"> <link rel='stylesheet' type='text/css' href='fullcalendar-1.6.1/fullcalendar/fullcalendar.css' /> </head> <body> <div id="dialog" title="dialog title"> <select id="titles"></select>    </div>  <div id='calendar'></div>  <script type="text/javascript" src="http://code.jquery.com/jquery.js"></script> <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script type="text/javascript" src="fullcalendar-1.6.1/fullcalendar/fullcalendar.min.js"></script> <script type="text/javascript"> //$(document).ready(function() {      // page ready, initialize calendar...       $( "#dialog" ).dialog({ autoopen: false });      $('#calendar').fullcalendar({     dayclick: function(date, allday, jsevent, view) {         $('#titles').find('option').remove(); //remove old options          /* titles via json */          $.getjson('titles.php', function(data) {            $.each(data, function(key, val) {               //$("#titles").append(new option(val.tostring(),key));              /* add val key demo it*/              $("#titles").append(new option(val.tostring(),val.tostring()));           });           });          $( "#dialog" ).dialog({buttons: { "ok": function()          {                  /* add event calendar */                 $('#calendar').fullcalendar( 'addeventsource', [{title: $("#titles").val(), start:date}]);                 $( ).dialog( "close" );          }}});         $( "#dialog" ).dialog("open");     } });   //}); </script> </body>  </html> 

titles.php:

    <?php     header('content-type: application/json');     $rows = array('title one','title two','title three');     echo json_encode((object)$rows);     exit; 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -