2016-11-07 7 views
0

だから私はcodeigniter 3を使用しています。 私のカレンダーから開始日と終了日をデータベースに挿入する方法を教えています。 これは私のjsのコードです:カレンダーの開始日と終了日をデータベースに挿入するにはどうすればいいですか

CalendarApp.prototype.onSelect = function (start, end, allDay) { 
    var $this = this; 
     $this.$modal.modal({ 
      backdrop: 'static' 
     }); 
     var form = $("<form action='http://localhost/somokos/profile/calendrier/somokos/create_event' enctype='multipart/form-data' method='post' accept-charset='utf-8'></form>"); 
     form.append("<div class='row'></div>"); 
     form.find(".row") 
      .append("<div class='col-md-6'><div class='form-group'><label class='control-label'>Event Name</label><input class='form-control' placeholder='Insert Event Name' type='text' name='title'/></div></div>") 
      .append("<div class='col-md-6'><div class='form-group'><label class='control-label'>Category</label><select class='form-control' name='color'></select></div></div>") 
      .find("select[name='color']") 
      .append("<option value='bg-danger'>Danger</option>") 
      .append("<option value='bg-success'>Success</option>") 
      .append("<option value='bg-purple'>Purple</option>") 
      .append("<option value='bg-primary'>Primary</option>") 
      .append("<option value='bg-pink'>Pink</option>") 
      .append("<option value='bg-info'>Info</option>") 
      .append("<option value='bg-warning'>Warning</option></div></div>"); 
     $this.$modal.find('.delete-event').hide().end().find('.save-event').show().end().find('.modal-body').empty().prepend(form).end().find('.save-event').unbind('click').click(function() { 
      form.submit(); 
     }); 
     $this.$modal.find('form').on('submit', function() { 
      var title = form.find("input[name='title']").val(); 
      var beginning = form.find("input[name='beginning']").val(); 
      var ending = form.find("input[name='ending']").val(); 
      var categoryClass = form.find("select[name='color'] option:checked").val(); 
      if (title !== null && title.length != 0 && beginning != 'beginning' && ending != 'ending') { 
       $this.$calendarObj.fullCalendar('renderEvent', { 
        title: title, 
        start:start, 
        end: end, 
        allDay: false, 
        className: categoryClass 
       }, true); 
       $this.$modal.modal('hide'); 
       return ; 
      } 
      else{ 
       alert('You have to give a title to your event'); 
      } 
      return false; 

     }); 
     $this.$calendarObj.fullCalendar('unselect'); 
}, 

私はPHPに渡したときに、私はこのエラーを取得します。 MySQL Error

+0

テーブル内の開始日と終了日のように見える作品必須で、あなたのコードは、いずれも返却されません挿入を続行する日付。 –

+0

Jamesに感謝しますが、どうすれば修正できますか? –

+0

コントローラとモデルを共有してもよろしいですか? – Jobayer

答えて

0

ありがとうございました。私は私のJSコードに

$('#lab1').val(start); 

と私のHTMLに

<input type='text' id='lab1'/> 

を追加し、それがおかげで再び

関連する問題