The error is on this line according to the browser console

Uncaught TypeError: Cannot set property 'onclick' of nullcal.php:26 (anonymous function)

When the a date is clicked other than in the january, april, novemeber the form doesnt opens.

the code on like 26 is from the console browser is

document.getElementById('trigger0').onclick = function()     
{showForm()};document.getElementById('trigger1').onclick = function()    
{showForm()};document.getElementById('trigger2').onclick = function() 
{showForm()};document.getElementById('trigger3').onclick = function() 
{showForm()};document.getElementById('trigger4').onclick = function() 
{showForm()};document.getElementById('trigger5').onclick = function() 
{showForm()};document.getElementById('trigger6').onclick = function() 
{showForm()};document.getElementById('trigger7').onclick = function()    
{showForm()};document.getElementById('trigger8').onclick = function() 
{showForm()};document.getElementById('trigger9').onclick = function() 
{showForm()};document.getElementById('trigger10').onclick = function() 
{showForm()};document.getElementById('trigger11').onclick = function() 
{showForm()};document.getElementById('trigger12').onclick = function() 
{showForm()};document.getElementById('trigger13').onclick = function() 
{showForm()};document.getElementById('trigger14').onclick = function() 
{showForm()};document.getElementById('trigger15').onclick = function() 
{showForm()};document.getElementById('trigger16').onclick = function() 
{showForm()};document.getElementById('trigger17').onclick = function() 
{showForm()};document.getElementById('trigger18').onclick = function() 
{showForm()};document.getElementById('trigger19').onclick = function() 
{showForm()};document.getElementById('trigger20').onclick = function() 
{showForm()};document.getElementById('trigger21').onclick = function() 
{showForm()};document.getElementById('trigger22').onclick = function() 
{showForm()};document.getElementById('trigger23').onclick = function() 
{showForm()};document.getElementById('trigger24').onclick = function() 
{showForm()};document.getElementById('trigger25').onclick = function() 
{showForm()};document.getElementById('trigger26').onclick = function() 
{showForm()};document.getElementById('trigger27').onclick = function() 
{showForm()};document.getElementById('trigger28').onclick = function() 
{showForm()};document.getElementById('trigger29').onclick = function() 
{showForm()};document.getElementById('trigger30').onclick = function() 
{showForm()};document.getElementById('trigger31').onclick = function()   
{showForm()};document.getElementById('trigger32').onclick = function()  
{showForm()};document.getElementById('trigger33').onclick = function()    
{showForm()};document.getElementById('trigger34').onclick = function()     
{showForm()};   function showForm(){

The code it relates to is:

$timestamp = mktime(0,0,0,$cMonth,1,$cYear);
$maxday = date("t",$timestamp);
$thismonth = getdate ($timestamp);
$startday = $thismonth['wday'];
$today = getdate();

for ($i=0; $i<($maxday+$startday); $i++) {

if(($i % 7) == 0 ) echo "<tr> ";

if($i < $startday) echo "<td></td> ";

  else echo "<td align='center' valign='middle' height='20px'><a href='#'    
 id='trigger" . $i . "'>". ($i - $startday + 1) . "</a></td>";  

  $jsEvent[] = "document.getElementById('trigger" . $i . "').onclick =     
 function() {showForm()};";

  if(($i % 7) == 6 ) echo "</tr> ";
  }
  ?>

the javascript code

<script type="text/javascript">
 <?php foreach($jsEvent as $event){
        echo $event;
     } ?>
 function showForm(){
     document.getElementById('timeslots').style.display="block";
 };
 </script>

One/multiple of those trigger## do not exist when you try to set the onclick. Why not make it a lot easier by just putting the show form call in the href of <a href='#'id='trigger" . $i . "'>".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.