1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
<html>
<head>
<title>tableau arborescent</title>
<style type='text/css'>
.case{
margin-left: 30px;
}
.liens{
text-decoration: none;
}
</style>
<script type='text/javascript'>
function swap(elem){
leparent = elem.parentNode;
disp = 'none';
minus = '<img src="TMimagesXL/minus01.gif" width="11" height="11" border="0" />';
plus= '<img src="TMimagesXL/plus01.gif" width="11" height="11" border="0" />';
if(elem.firstChild.innerHTML ==minus){
elem.firstChild.innerHTML = plus;
elem.lastChild.style.display = 'inline';
}
else{
elem.firstChild.innerHTML = minus;
elem.lastChild.style.display = 'none';
disp = 'block';
}
for(var i=1;i<leparent.childNodes.length;i++){
leparent.childNodes[i].style.display = disp;
}
}
window.onload = function(){
liens = document.getElementsByName('lesliens');
for(var i=0;i<liens.length;i++)
swap(liens[i]);
}
</script>
</head>
<body>
<?
function affiche($tab){
foreach($tab as $key => $value){
echo "<div align='left' class='case'>";
if(is_array($value))
{
echo '<a href="#" class="liens" name="lesliens" onclick="swap(this)"><span><img src="TMimagesXL/plus01.gif" width="11" height="11" border="0" /></span><b> ',$key,' </b><span class="count">(",is_array($value) ? count($value) : "1",")</span></a>';
affiche($value);
}
else
{
echo '<table cellpadding="0" cellspacing="0" border="1" width="80%" >';
echo "<tr align='left' bgcolor='#D4D0C8'><td bgcolor='#D4D0C8'><span>.</span> ",$key," </td>";
echo "<td width='50%' bgcolor='#ECE9D8'> ",$value,"</td></tr>";
echo "</table>";
}
echo "</div>";
}
}
$montab = array("Directions" => array("titre 001" => array("titre69" => "2012","titre 22" => "1235","titre 6 " => "1124"),"titre1" => array("titre2" => "2012","titre5" => "1235","titre3 " => "1124")));
affiche($montab);
?>
</body>
</html> |
Partager