www.webdeveloper.com
Results 1 to 4 of 4

Thread: Simple IF Statement To Call Class

Hybrid View

  1. #1
    Join Date
    Jul 2006
    Posts
    655

    Simple IF Statement To Call Class

    Hi, i have just finished coding a design into html / css. I have spit the code up into php includes for the HEADER, NAVIGATION and the FOOTER

    I have coded my navigation so that when a tab (page) is selected from navigation it has a different style. I have declared this style in the css called .selected

    Can someone help me write a simple IF statement, that will work like this:

    IF the current page is 'contact.php' echo '.selected' ELSE do nothing

    I was hoping to past this IF statement into the code for each tab / button so it would use the .selected class if it was on that page, thanks in advance for your help...

  2. #2
    Join Date
    Dec 2011
    Posts
    163
    I think you want JavaScript...

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,247
    PHP Code:
    <p class='some classes <?php echo (basename($_SERVER["SCRIPT_NAME"]) == 'contact.php') ? ' .selected' ''?>'>foo</p>
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    Jul 2006
    Posts
    655
    Cool, thanks for that NogDog

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles