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
| <html>
<head>
<title>tableaux</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';
if(elem.firstChild.innerHTML == '-'){
elem.firstChild.innerHTML = "+";
elem.lastChild.style.display = 'inline';
}
else{
elem.firstChild.innerHTML = "-";
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 class='case'>";
echo "<a href='#' class='liens' name='lesliens' onclick='swap(this)'><span>-</span> ",
$key," <span class='count'>(",is_array($value) ? count($value) : "1",")</span></a>";
if(is_array($value))
affiche($value);
else
echo "<div class='case'>",$value,"</div>";
echo "</div>";
}
}
$montab = array("a" => array("b" => array("f" => "bla","g" => "bla"),
"c" => array("d" => "bla","e" => "bla")),"h" => "bla");
affiche($montab);
?>
</body>
</html> |
Partager