Results 1 to 8 of 8

Thread: when link is active, disable it

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    21

    when link is active, disable it

    Is it possible to have links on a page change color and disable when they are active, it's an added touch to a link. Normally you can just set active link color, but I was curious if you could make the link turn to text when active.

  2. #2
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    I'm going to assume that you're talking about some sort of navigation system. You can do anything you want with switches in the URL. It could get very complex, but basically you'd have to set a series of flags and include it in the URL.

    There is no way using CSS to do this like a:active = nolink or something as simple as that.

    Colors are also possible, but would have to follow the same routine as setting the links to text.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: when link is active, disable it

    Originally posted by J_Man
    Is it possible to have links on a page change color and disable when they are active, it's an added touch to a link. Normally you can just set active link color, but I was curious if you could make the link turn to text when active.
    I'm not really sure what you mean.

    Do you mean a navigation system, whereby when the user clicks the link in the navigation bar, the page loads and the link turns to standard text?

    If so this is relitively simple with PHP. Have a look at the example below:
    PHP Code:
    <?php 
        header 
    ('Content-Type: text/html; charset=iso-8859-1'); 
        
    $location = (isset ($_GET['location'])?$_GET['location']:'home');
        
        
    /*  array of items you want to include in your navigation bar
         *  the key corresponds to the query string values and the value 
         *  corrsesponds to the link text
         */   
        
    $navbar = Array ('home' => 'Home',
                         
    'link1' => 'Link 1',
                         
    'link2' => 'Link 2',
                         
    'link3' => 'Link 3',
                         
    'link4' => 'Link 4');
        
    ?>
    <!DOCTYPE html 
         PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
        <head>
            <title>Links</title>
        </head>
        <body>
            <div class="main">        
    <div>
        <h2>Navigation Bar</h2>
        <table class="navbar">
            <tr>
    <?php foreach ($navbar as $key => $value): ?>
                <td>
    <?php   if ($location != $key): ?>
                    <a href="<?php link_self("location=$key")?>"><?php echo ($value?></a>
    <?php   else: echo ($value?>
                </td>
    <?php endif; endforeach; ?>
            </tr>
        </table>
    </div>
        </body>
    </html>
    <?php

        
    function link_self ($querystring '') {
            echo (
    htmlspecialchars ($_SERVER['SCRIPT_NAME'] . ($querystring == ''?'':"?$querystring")));
        }
    ?>
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    21
    how do I make it display like a list? it comes out horizontal, I can't change it

  5. #5
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Put a <br> or 2 after each one?
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    Change the middle bit of the code to this. It uses table rows.
    PHP Code:
    <?php foreach ($navbar as $key => $value): ?>
        <tr>
                <td>
    <?php   if ($location != $key): ?>
                    <a href="<?php link_self("location=$key")?>"><?php echo ($value?></a>
    <?php   else: echo ($value); endif; ?>
                </td>
        </tr>
    <?php endforeach; ?>
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    21
    Originally posted by ober0330
    Put a <br> or 2 after each one?
    it's not designed like that

  8. #8
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Sorry... it's Monday morning. I wasn't thinking straight.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

Posting Permissions

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



Click Here to Expand Forum to Full Width