Jump to content



Photo

Use Javascript to click through months

javascript jquery

  • Please log in to reply
6 replies to this topic

#1 brad5023

brad5023

    Resident One Post Wonder

  • Joined: 02-March 14

Posted 02 March 2014 - 09:21

Hi guys,

I have got a calendar together which displays the days of the month but I'd like to use a couple of javascript buttons on the page to increase and decrease the "$newdate = strtotime('+0 month', $current_month);" to allow the users to click through the different months. Well, this is how I'd do it but I'm open to suggestions on how to click through the months.

Any help would be amazing. Thank you for reading this.

<?php

date_default_timezone_set('Europe/London');

$current_month = time();

$newdate = strtotime('+0 month', $current_month);


$day = date('d', $newdate) ;
$month = date('m', $newdate) ;
$year = date('Y', $newdate) ;

$first_day = mktime(0,0,0,$month, 1, $year) ;

$title = date('F', $first_day) ;


$day_of_week = date('D', $first_day) ;


switch($day_of_week){

case "Mon": $blank = 0; break;

case "Tue": $blank = 1; break;

case "Wed": $blank = 2; break;

case "Thu": $blank = 3; break;

case "Fri": $blank = 4; break;

case "Sat": $blank = 5; break;

case "Sun": $blank = 6; break;

}


$days_in_month = cal_days_in_month(0, $month, $year) ;


$day_count = 1;


while ( $blank > 0 )

{

echo "<div class=\"spacer\">
<a href=\"#\"></a>
</div>";

$blank = $blank-1;

$day_count++;

}


$day_num = 1;


while ( $day_num <= $days_in_month )

{

echo "<div class=\"number_block\">
<a href=\"#\">$day_num</a>
</div>";

$day_num++;

$day_count++;

}

?>



#2 +Seahorsepip

Seahorsepip

    http://seapip.com

  • Tech Issues Solved: 17
  • Joined: 23-January 11
  • Location: Netherlands
  • OS: Windows 8.1 Pro
  • Phone: Nexus 5

Posted 02 March 2014 - 11:21

I'd just use a jquery calendar like this: http://arshaw.com/fullcalendar/

Or this(though it does not support events for a specific time): http://tympanus.net/...alendar-plugin/



#3 +Nik L

Nik L

    Where's my pants?

  • Tech Issues Solved: 2
  • Joined: 14-January 03

Posted 02 March 2014 - 11:49

I was going to suggest jQueryUI calendar :)



#4 +Seahorsepip

Seahorsepip

    http://seapip.com

  • Tech Issues Solved: 17
  • Joined: 23-January 11
  • Location: Netherlands
  • OS: Windows 8.1 Pro
  • Phone: Nexus 5

Posted 02 March 2014 - 12:14

I was going to suggest jQueryUI calendar :)

I also thought of that but jqueryui is so bloated feeling for me :/



#5 +Nik L

Nik L

    Where's my pants?

  • Tech Issues Solved: 2
  • Joined: 14-January 03

Posted 02 March 2014 - 12:21

It is, but use the core and load in the modules you need?  Still somewhat bloated for such functionality though...



#6 +Seahorsepip

Seahorsepip

    http://seapip.com

  • Tech Issues Solved: 17
  • Joined: 23-January 11
  • Location: Netherlands
  • OS: Windows 8.1 Pro
  • Phone: Nexus 5

Posted 02 March 2014 - 13:23

It is, but use the core and load in the modules you need?  Still somewhat bloated for such functionality though...

Yeah and happy birthday



#7 +Nik L

Nik L

    Where's my pants?

  • Tech Issues Solved: 2
  • Joined: 14-January 03

Posted 02 March 2014 - 13:31

Cheers pal.  Have followed u on here, reckon I could learn a bit ;)