Jump to content

Can anyone help me to make my menu able to hide/show? Thanks a lot.


zac1987

Recommended Posts

Currently my this menu can only show but cannot hide. when I click on a category, it shows a list of items. When I click again the category, the list of items must hide back. How is the code to hide back the list of items? Could anyone help me? Thanks. I am newbie in PHP, so please show me the code in more detail. Thanks.untitled.PNG

 

Below is the coding. Hope someone can help me modify it so that when I click 2nd time the category, it will hide the items. click 3rd time, it will show items. click 4th time, it will hide...

 

function public_navigation($sel_category, $sel_item){

$output = "<div style=\"overflow:auto; height:435px; width:250px;\" name=\"content\" ><ul class=\"categories\">";

$category_set = get_all_categories();

while ($category = mysql_fetch_array($category_set)) {

$output .= "<li";

if ($category["id"] == $sel_category['id']){ $output .= " class=\"selected\""; }

$output .= "><a href=\"index.php?category=" . urlencode($category["id"]) . "\">{$category["category"]}</a></li>";

 

if ($category["id"] == $sel_category['id'] || $category["id"] == $sel_item['category_id']){

$item_set = get_items_for_categories($category["id"]);

 

$output .= "<ul class=\"items\">";

while ($item = mysql_fetch_array($item_set)) {

$output .= "<li";

if ($item["id"] == $sel_item['id']){$output .= " class=\"selected\"";}

$output .= "><a href=\"index.php?item=" . urlencode($item["id"]) . "\">{$item["item"]}</a></li>";

}

$output .= "</ul>";

}

}

$output .= "</ul></div>";

return $output;

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.