I copy and pasted your code and ran it on my local xampp server and your page doesn't even display properly in my IE9.
Below is the html generated by your code (from View Source in the browser) that is sent back to the browser. In it you can see there is still some php code which obviously shouldn't be there.
You need to fix your php code so it generates the correct html before playing with the javascript.
Code:
<html>
<head>
<script language="javascript">
function mysqlTimeStampToDate(timestamp) {
//function parses mysql datetime string and returns javascript Date object
//input has to be in this format: 2007-06-05 15:26:02
var regex=/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9]) (?: ([0-2][0-9]): ([0-5][0-9]): ([0-5][0-9]))?$/;
var parts=timestamp.replace(regex,"$1 $2 $3 $4 $5 $6").split(' ');
//alert(parts);
return new Date(parts[0],parts[1]-1,parts[2],parts[3],parts[4],parts[5]);
}
function checkTable(tabelnaam, keuze){
var urenvan = [];
var urentot = [];
var actok = [];
var tabel = document.getElementById(tabelnaam);
var trs = tabel.getElementsByTagName("span");
for(var i=0;i<trs.length;i++)
{
var sp = trs[i].id.split("-");
if (sp[0]=="actvan"){
actok.push("NEW");
urenvan.push(trs[i].innerHTML);
}else{
urentot.push(trs[i].innerHTML);
}
}
for(var i in urenvan)
{
if (i != keuze){
van1 = mysqlTimeStampToDate('2010-01-01 '+urenvan[keuze]);
tot1 = mysqlTimeStampToDate('2010-01-01 '+urentot[keuze]);
van2 = mysqlTimeStampToDate('2010-01-01 '+urenvan[i]);
tot2 = mysqlTimeStampToDate('2010-01-01 '+urentot[i]);
if(van1 > van2 && tot1 < tot2)
{ //-> Check time is in between start and end time
actok[i]="NIETOK";
}else if((van1 > van2 && van1 < tot2) || (tot1 > van2 && tot1 < tot2))
{ //-> Check start or end time is in between start and end time
actok[i]="NIETOK";
}else if(van1==van2 || tot1==tot2)
{ //-> Check start or end time is at the border of start and end time
actok[i]="OK";
}else if(van2 > van1 && tot2 < tot1)
{ //-> start and end time is in between the check start and end time.
actok[i]="OK";
}
}
}
alert(actok.join('\n'));
for(var o in actok)
{
if(o != keuze){
var rij = "rij"+o;
if (actok[o]=="NIETOK"){
document.getElementById[rij].style.display='none';
}else{
document.getElementById[rij].style.display='block';
}
}
}
}
</script>
</head>
<body>
<table width="500" border="1" id="activiteiten">
<?
foreach ($uren as $key => $value) {
?>
<tr id="rij<?= $key ?>"><td><input type="checkbox" name="act<?= $key ?>"></td><td><?= $key ?></td><td><span id="actvan-<?= $key ?>"><?= $value["van"] ?></span></td><td><span id="acttot-<?= $key ?>"><?= $value["tot"] ?></span></td></tr>
<?
}
?>
</table>
<input type="button" value="test 0" onclick="javascript:checkTable('activiteiten', '0');">
<input type="button" value="test 1" onclick="javascript:checkTable('activiteiten', '1');">
<input type="button" value="test 2" onclick="javascript:checkTable('activiteiten', '2');">
<input type="button" value="test 3" onclick="javascript:checkTable('activiteiten', '3');">
</body>
</html>
Bookmarks