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 6 of 6
  1. #1
    New Coder
    Join Date
    Jan 2009
    Posts
    48
    Thanks
    28
    Thanked 0 Times in 0 Posts

    links not active

    Hi,

    I can get links from txt document but the links aren't active i.e. can't click on them there just text. Any ideas of how to get them active:
    <?php
    =====================
    echo '<ul>';
    foreach ($elements as $kw){
    echo '<li>' .htmlentities($kw->nodeValue).
    '('.htmlentities($kw->getAttribute('href')).')</li>';
    }
    echo '</ul>';
    ?>
    thanks is advance

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Basic HTML: wrap them in an anchor tag.
    Are you a Help Vampire?

  • Users who have thanked tomws for this post:

    tau9 (03-23-2009)

  • #3
    New Coder
    Join Date
    Jan 2009
    Posts
    48
    Thanks
    28
    Thanked 0 Times in 0 Posts
    thanks for the reply

    I have tried adding <a> </a> tags but doesn't seem to work.

  • #4
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    What does the actual html look like after you do that?
    Are you a Help Vampire?

  • Users who have thanked tomws for this post:

    tau9 (03-24-2009)

  • #5
    Senior Coder TheShaner's Avatar
    Join Date
    Sep 2005
    Location
    Orlando, FL
    Posts
    1,126
    Thanks
    2
    Thanked 40 Times in 40 Posts
    Without knowing how your $elements object array is set up, I'm guessing that $kw->getAttribute('href') returns the link you want to click on. Based on that assumption, try the below. This is what tomws wants you to do:
    PHP Code:
    foreach ($elements as $kw){
      echo 
    '<li>' .htmlentities($kw->nodeValue).
      
    '(<a href="'.htmlentities($kw->getAttribute('href')).'">'.htmlentities($kw->getAttribute('href')).'</a>)</li>';
    }
    echo 
    '</ul>'
    The above is printing the link with it wrapped in anchor tags. What you also need is the HREF in the anchor tag to be set to the link. So you must print the link twice: once for the HREF and once to display the link to the screen to be clicked on.

    -Shane

  • Users who have thanked TheShaner for this post:

    tau9 (03-24-2009)

  • #6
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    4
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by tau9 View Post
    thanks for the reply

    I have tried adding <a> </a> tags but doesn't seem to work.
    Adding only <a> </a> never works.

    <a href="XXX"></a> will works.

  • Users who have thanked webh4x0r for this post:

    tau9 (03-24-2009)


  •  

    Posting Permissions

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