DIV Link

Discussion in 'PHP' started by Salchester, Jul 20, 2007.

  1. #1
    Hiya Guys,

    How do I adapt the following code, so the ButPrevEna div becomes a link like href?

      echo '<div id="ButPrevEna">';
      echo "<a href=\"./Display.php?id=" . ($start - $perpage) . "\" class=\"NavEna\">Previous Screen</a>";
      echo '</div>';
    Code (markup):
    Many Thanks, in advance!

    Salchester.
    The Future Is Here - Are You Ready?
     
    Salchester, Jul 20, 2007 IP
  2. mgware

    mgware Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you mean this?

    
      echo '<a href="./Display.php?id='.($start - $perpage).'" class="NavEna"><div id="ButPrevEna">Previous Screen</div></a>';
    
    Code (markup):
     
    mgware, Jul 21, 2007 IP
  3. mrmonster

    mrmonster Active Member

    Messages:
    374
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #3
    <div onclick="openURL('www.microsoft.com')">Hello World, I'm clickable</div>

    <script language="javascript>

    function openURL(url){
    window.location = url;
    }

    </script>


    :)

    Style your div as desired.
     
    mrmonster, Jul 21, 2007 IP
  4. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #4
    You can also do this which normally works well and doesn't require javascript.

    Style the a tag exactly like you would with the division itself using display:block. Use css to make the link look however you want it. You can set height and width. I prefer to use padding because it will be clickable anywhere.

    
    <style type="text/css">
    
    a.NavEna {
    display:block;
    width:100%;
    padding: 10px 0;
    margin:5px;
    color:#333;
    background:#eee;
    }
    
    </style>
    
    <?php
    
    echo "<a href=\"./Display.php?id=" . ($start - $perpage) . "\" class=\"NavEna\">Previous Screen</a>";
    
    ?>
    
    
    Code (markup):
     
    jestep, Jul 21, 2007 IP