Note that there are some explanatory texts on larger screens.

plurals
  1. POChange variable in PHP script and run function again, without reloading page
    primarykey
    data
    text
    <p>can someone tell me if I need AJAX to do what I need here? I have this function which creates a calendar. I'm going to insert some 'forward' and 'backward' arrows keys so the user can scroll through the months.</p> <p>So on clicking the forward button; I want to get the next month - and display that month instead of the one present. This means reloading the function, right? But with a different variable for month. Also, I can't have the PHP display itself once more without using JavaScript of some sort, right?</p> <p>I know I can make the same calendar with JavaScript but I want to see how it works using PHP. I've also never used AJAX functionality before, I'm not sure how I'd change the variable of a script in this way really..</p> <pre><code>function create_Calendar($month,$year){ $i = ""; $days_array = array("Mon","Tue","Wed","Thur","Fri","Sat","Sun"); $days_in_month = cal_days_in_month(CAL_GREGORIAN,$month,$year); $jd = cal_to_jd(CAL_GREGORIAN,$month,date("d"),$year); $first_day = jddayofweek($jd,0); $month_name = jdmonthname($jd,3) . " " . date("Y"); echo("&lt;div id='calendar'&gt;"); echo("&lt;div id='month_name'&gt;" . $month_name . "&lt;/div&gt;"); for($i=0;$i&lt;7;$i++){ echo("&lt;div class='day_titles'&gt;" . $days_array[$i] . "&lt;/div&gt;"); } for($i=0;$i&lt;$first_day;$i++){ echo("&lt;div class='blank_days'&gt;&lt;/div&gt;"); } for($i=1;$i&lt;=$days_in_month;$i++){ echo("&lt;div class='day'&gt;" . $i . "&lt;/div&gt;"); } echo("&lt;div class='day_tooltip'&gt;&lt;/div&gt;"); echo("&lt;/div"); }; </code></pre> <p>I am calling the function with:</p> <pre><code>create_Calendar(date("m"),2013); </code></pre> <p>Any help is appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload