I have two <a></a>
tags which holds the onclick
event and has PHP code in it. Obviously I need them to work. What those links do - switch between months. Here are the links.
<a href="javascript:void(0);" onclick="getCalendar('calendar_div','<?php echo date("Y",strtotime($date.' - 1 Month')); ?>','<?php echo date("m",strtotime($date.' - 1 Month')); ?>');"><span class="glyphicon glyphicon-chevron-left"></span></a>
<select name="month_dropdown" class="month_dropdown dropdown"><?php echo $this->getAllMonths($dateMonth); ?></select>
<select name="year_dropdown" class="year_dropdown dropdown"><?php echo $this->getYearList($dateYear); ?></select>
<a href="javascript:void(0);" onclick="getCalendar('calendar_div','<?php echo date("Y",strtotime($date.' + 1 Month')); ?>','<?php echo date("m",strtotime($date.' + 1 Month')); ?>');"><span class="glyphicon glyphicon-chevron-right"></span></a>
As you can see I have the $this->
pointer in <select></select>
tags which allows it to be in use because I am using classes and there has to be the pointer there I assume. So how do I get the tags to work? When I add the $this->
pointer to the onclick
event in front of getCalendar
the PHP code just breaks down.
Do I have to use some other method in order to achieve what I am after?
The pseudo-variable $this
is available when a method is called from within an object context. If your code is not part of class definition, you must create object first:
$obj = new Class();
Then use class methods with:
$obj->getAllMonths($dateMonth);
.
You can read this about PHP classes.
check this code. you are add '<?php echo date("Y",strtotime($date.' - 1 Month')); ?>'
here single cotetion remove this.
<a href="javascript:void(0);" onclick="getCalendar('calendar_div',<?php echo date("Y",strtotime($date.' - 1 Month')); ?>,<?php echo date("m",strtotime($date.' - 1 Month')); ?>);"><span class="glyphicon glyphicon-chevron-left"></span></a>
<select name="month_dropdown" class="month_dropdown dropdown"><?php echo $this->getAllMonths($dateMonth); ?></select>
<select name="year_dropdown" class="year_dropdown dropdown"><?php echo $this->getYearList($dateYear); ?></select>
<a href="javascript:void(0);" onclick="getCalendar('calendar_div',<?php echo date("Y",strtotime($date.' + 1 Month')); ?>,<?php echo date("m",strtotime($date.' + 1 Month')); ?>);"><span class="glyphicon glyphicon-chevron-right"></span></a>