Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder che_anj's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    157
    Thanks
    12
    Thanked 3 Times in 3 Posts

    anyone can relate my problem? change bgcolor of menu when click

    Hello, I have a horizontal menus, using css. I would like to change the color of 1 column in menu when click the said column.. I actually have this code well the idea is already there, but my problem is, since the menus are member of the while condition, all columns has been changed.. I want only one column change the bgcolor when it clicked itself.
    PHP Code:
    $sql "SELECT code, menuname, link FROM menus WHERE parent = $code AND acl >= $_SESSION[acl] ORDER BY code, parent";
        
    $res $db->query($sql);
        
    $url_menu=explode("&",GetURL($link));
        
    $urls=explode("="$url_menu[1]);
        
    $menname=$urls[1];
        while (
    $row $res->fetch_assoc()) 
        {  
        echo 
    "<li style='border-left: 1px solid #202020;'><a href='$row[link]'"
                 if (
    $menname == '1') { echo "class='current'"; } else if ($menname == '2') { echo "class='current'";} else { echo "class=''";}echo ">$level $row[menuname]</a></li>";
            
        }
        }    
    dbMenu(); 
    thanks for the help..

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,389
    Thanks
    8
    Thanked 1,077 Times in 1,068 Posts
    How do you know which column you've selected?
    Is there one variable there that is associated with a column?

  • #3
    Regular Coder che_anj's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    157
    Thanks
    12
    Thanked 3 Times in 3 Posts
    what i did is I get the current url of page,

    $url_menu=explode("&",GetURL($link));
    $urls=explode("=", $url_menu[1]);
    $menname=$urls[1];

    http://mytestweb/_femploy/menu.php?c...ist.php&menu=1

    $menname=$urls[1];

    so the $menname= menu 1.

    Home | Client | Jobs | Candidates |

    if im going to click the Client the current url will be above and explode the url to get the menu which is equal to 1 and put the condition inside the loop

    while ($row = $res->fetch_assoc())
    {
    echo "<li style='border-left: 1px solid #202020;'><a href='$row[link]'";
    if ($menname == '1') { echo "class='current'"; } else if ($menname == '2') { echo "class='current'";} else { echo "class=''";}echo ">$level $row[menuname]</a></li>";

    }

  • #4
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,389
    Thanks
    8
    Thanked 1,077 Times in 1,068 Posts
    So ... I'm still working on understanding it.

    When they click "Client" in your menu, it will then
    display the clients, and you want the menu on that page
    to change ... example:

    Home | Client | Jobs | Candidates |

    Now, because they are viewing the list of Clients, that menu
    selection is now highlighted different from the others?

    This has nothing to do with the loop or list, but the menu itself?

    Is that what you mean?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •