我的JavaScript函数在php中不起作用


My JavaScript function doesn't work in the php

我的JS函数找到的名称正在破坏代码。当我删除它时,JS是有效的。函数中的两个警报都不起作用。这是代码。可能有点困惑,但重要的是JS中的JS功能和警报。

我正在使用记事本++,HTML输出什么都没有。我想查看警报。

<html> 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
        table.Ekim {table-layout:fixed;}
    table.Ekim td{text-align: left; vertical align:top;width:14.2%;height:20%}
</style>
<head>

<body>

<?php
   header('Content-type: text/html; charset=utf-8');

$doc = new DomDocument(); 
$site = 'http://www.etu.edu.tr/?q=tr/takvim'; 
$deneme ="ali";
$olay = array();
$tarih = array();

if (@$doc->loadHTMLFile($site)) {    
$items = $doc->getElementsByTagName('div');     
foreach($items as $item) {
    if ($item->getAttribute("class") == "takvim-olay"){  
            $str = $item->nodeValue;  
array_push($olay,utf8_decode($str));
    }
}
  $items = $doc->getElementsByTagName('div');    
foreach($items as $item) {
    if ($item->getAttribute("class") == "takvim-tarih"){  
            $str = $item->nodeValue;  

array_push($tarih,utf8_decode($str));
        }
    }
}

?>
<script type="text/javascript">
alert("start");
var olay = <?php echo json_encode($olay);?>; 
var tarih = <?php echo json_encode($tarih);?>;

function find(){
    for(var j = 0;j<tarih.length;j++){    
          if(tarih[j].indexOf("Ekim")!=-1)
          {     
            if(tarih[j].indexOf("-")!=-1)
            {
                var pieces=tarih[j].split(" - ");
                if (pieces[0] <= pieces[1])
                {
                    var a=pieces[0];
                    for(var i=0; i<((pieces[1]-pieces[0])+1); i++)
                    {
                        boolean ctrl = true;
            for(var f = 0 ; f<ekim[a].length ;      f++){
                if(ekim[a][f] == olay[j]){
                                ctrl = false;
                            }
                        }
                        if(ctrl){
                            ekim[a++].push(olay[j]);
                        }
                    }
                }
                else 
                {
                    //some occ
                }
            }
            else if (tarih[j].indexOf(",") != -1) 
            {
               pieces=tarih[j].split(", ");
               for(var i=0; i<pieces.length; i++)
               {
               boolean ctrl = true;
               for(var o = 0 ; o<ekim[pieces[i]].length;o++){
                if(ekim[pieces[i]][o] == olay[j]){
                    ctrl = false;
                }
               }
               if(ctrl){
                ekim[pieces[i]].push = olay[j];
               }
               }
            }
            else
            {
            boolean ctrl = true;
                for(var t = 0; t<ekim[tarih[j]].length;t++){
                    if(ekim[tarih[j]][t] == olay[j]){
                        ctrl=false;
                    }
                }
                if(ctrl){
                    ekim[tarih[j]].push(olay[j]);
                }
            }
          } 
        }
}

    alert("end");

</script>

</body>
</html>

问题是

boolean ctrl = true;

这不是有效的JavaScript。可能,你想要

ctrl = true;