I have a little problem ... my menu.php does not work and i dunno why
heres my index:
<html>
<?php
function writeOut($pageName)
{
$buffer = fopen($pageName, r);
$data = fread($buffer, filesize($pageName));
fclose($buffer);
echo($data);
}
writeOut('head.html');
echo('<body><div id="top">');
writeOut('top.html');
echo('</div>');
/*
in case of anomalies
ob_start();
include 'menu.php';
$result = ob_get_clean();
*/
include 'menu.php';
echo('');
// reserved for content
echo('');
writeOut('right.html');
echo('</body>');
?>
</html>
and my menu.php:
<?php
/* Example in menu_skuska.html */
$buffer = '';
function addMenuHeader($header_name,$id,$distance_from_top,$distance_from_left)
{
$buffer = $buffer + '<div style="position:absolute; top:' + $distance_from_top + '; left:' + $distance_from_left + ';">';
$buffer = $buffer + '<p onClick="toggleMenu(' + $id + ')" id="menu_header">' + $header_name + '</p>';
$buffer = $buffer + '<div id="' + $id + '" style="visibility:hidden;">';
}
function addMenuItem($item_name,$link)
{
$buffer = $buffer + '<a href="' + $link + '">' + $item_name + '</a><br>';
}
function finalizeMenu()
{
$buffer = $buffer + '</div></div>';
}
function printMenu()
{
echo($buffer);
}
addMenuHeader('Click me','menu1','100px','100px');
addMenuItem('Google','http://www.google.com');
addMenuItem('Facebook','http://www.facebook.com');
finalizeMenu();
printMenu();
?>
<script>
function toggleMenu(obj)
{
if (obj.style.visibility == "visible")
{
obj.style.visibility = "hidden";
}else obj.style.visibility = "visible";
}
</script>
the menu.php is meant to generate somethink like this:
<div style="position:absolute; top:10%; left:10%; color:green;">
<p onClick="ToggleMenu(toggled)" style="cursor: pointer;">skuska</p>
<div id="toggled" style="visibility:hidden;">
skuska2<br>
skuska3
</div>
</div>
<script>
function ToggleMenu(obj)
{
if (obj.style.visibility == "visible")
{
obj.style.visibility = "hidden";
}else obj.style.visibility = "visible";
}
</script>
so why does menu.php simply echo nothink??