0

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>
2
Contributors
1
Reply
23
Views
2 Years
Discussion Span
Last Post by Traevel
0

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 . "'>".

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.