|  |  | 
          
            | Code (JavaScript) 
 
<script>
function daysInMonth(month,year) {
    return new Date(year, month, 0).getDate();
}
function get_date(month,year){
	var year = year;
	var month = month;
	var getTot = daysInMonth(month,year); //Get total days in a month
	var weekend = new Array();   //Declaring array for inserting Saturdays
	var sun = new Array();   //Declaring array for inserting Sundays
  for(var i=1;i<=getTot;i++){    //looping through days in month
    var newDate = new Date(year,month,i)
    if(newDate.getDay()==0 || newDate.getDay()==0 ){   //if Sunday
        weekend.push(i);
    }
   
   return weekend;
}
}
	
 
       $('#calendar').fullCalendar({
      header    : {
        left  : 'prev,next today',
        center: 'title',
        right : 'month,agendaWeek,agendaDay'
      },
      buttonText: {
        today: 'today',
        month: 'month',
        week : 'week',
        day  : 'day'
      },
      events: [ 
   
      <?php foreach ($result as $index => $r) {  
      	$year = $r->year_quota;
      	if($r->month_quota == 10 || $r->month_quota == 11 || $r->month_quota == 12) {$month = $r->month_quota;}
      	else{$month = '0'.$r->month_quota ;}   ?>
      	
	weekend = get_date($month,$year);   // <------ ตรงนี้ที่เขียนเรียกใช้ฟังก์ชัน 
 
 	
 	{
      id: 'a',
      title: '<?php echo  $r->balance_quota; ?>',
      start: '<?php echo $r->year_quota.'-'.$month.'-'   ?>',
    },
   
<?php } ?>
  ]
</script>
 
 
 คือผมต้องการหาวันเสาร์และอาทิตย์จากเดือนและปีที่ผมมี ซึงผมได้ทำการสร้างฟังก์ชันสำหรับหาค่าวันเสาร์และอาทิตย์ แต่ผมยังติดตรงที่ผมต้องการส่งค่าไปยังฟังก์ชันที่ผมต้องการแต่ไม่สามารถทำได้ ผมจึงอยากสอบถามว่าผมควรเขียนเรียกฟังก์ชัน ตรงไหน หรือเขียนอย่างไรครับ
 
 Error ที่เจอคือ  Uncaught SyntaxError: Unexpected token ;  เจอตรงบรรทัดที่ผมเขียนเรียกฟังก์ชันครับ
 
 
 
 Tag : PHP, JavaScript, jQuery
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2019-04-26 17:06:24 | By :
                          simson_palo | View :
                          1049 | Reply :
                          1 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |