0

データベースからのデータを処理するため、独自のJavaScript カレンダーを作成しました。前のボタンを使用して任意の月を表示できるように、ユーザーにオプションを提供したいと考えています。このカレンダーは機能しますが、次のボタンが機能しません。私のコードは::

私のphpファイル::

myfile.php

<!DOCTYPE html>
<html lang="en">
   <head>
      <script src="../_javaScript/jquery-1.9.1.js" type="text/javascript"> </script> 
      <!-- call calender.js file  -->
      <script src="../_javaScript/calender.js" type="text/javascript"> </script>
   </head>

 <body> 
      <div id="calander">            
        <script type="text/javascript">                 
    $("document").ready( function()  {
        var dayData = <?php echo json_encode($dayArray); ?>;  // data from database using json_encode function                      
        var thisDate = new Date();  // present time

        var thisMonth = thisDate.getMonth();   // present month
        var thisYear  = thisDate.getFullYear();  // present year                            
        makeCalender(dayData, thisMonth, thisYear); // call to display calender
    });     
     </script>  <!-- end of script -->

      </div>  <!-- end of calender  -->

 </body>  <!-- end of body -->

</html>

私のcalender.jsファイル。ここですべてがうまく機能し、私の唯一の問題は、次のボタンが機能しないことです。

カレンダー.js

 function  makeCalender(dayData, thisMonth, thisYear) {
 // calculation for calender
 // this part I make some calculation which is worked well      

 // now design calender table
 var designTable = "";

// some calender code for designing and making calender 

 designTable += "<table>";

 designTable += "<tr>";

    // calender 

 designTable += "</tr>";

 designTable += "<tr>";

  // this  prev button (before commented) doesn't work
 /*designTable  += "<td> <input type='button' name='prevMonth' value='&lAarr' onclick='makeCalender(" + dayDate + "," + thisMonth + "," + thisYear +")' /> </td>"; */

   // this prev button also doesn't work
 designTable  += "<td> <input type='button' name='prev' value='prev' onclick=\'" + "makeCalender(" + dayData + ", " + prevMonth + ", " + prevYear + ");\' /> </td>";

   designTable  += "  <td> &nbsp; </td> <td> &nbsp; </td> <td> &nbsp; </td> <td> &nbsp; </td> <td> &nbsp; </td> ";

// this next button does not work
    designTable  += "<td> <input type='button' name='next' value='>>' onclick='alert(\"makeCalender( " +  dayData + ", " + nextMonth + ", " + nextYear + " )\");' /> </td>";

     // this next button (before commented)  also doesn't work
/* designTable  += "<td> <input type='button' name='nextMonth' value='&rAarr' onclick='makeCalender("  + dayDate + "," + nextMonth + "," + nextYear ")' /> </td>" */

 designTable += "</tr>";

 designTable  +=  "</table>";

 // now print this table into "calander" part in "myfile.php" 
 document.getElementById("calander").innerHTML = designTable; 

}
4

0 に答える 0