SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    find a value inside of class and display a link

    Hi all we are in desperate need of a solution, we have tried and search different methods but none of us can figure it out.

    Basically we need to find a word which is inside a class and display a link.

    So something like this

    find a word equal to "1 line custom"

    then

    display this <a href="/1-line-custom.htm">click here</a>

    I'm not sure if this is really simple or not.

    Any help would be much appreciated.

    Thanks

    Will

  2. #2
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok so we are getting close, basically what this is doing now is finding the words inside a class then showing us them in an alert.



    Code:
    <table>
      <tbody>
        <tr>
          <td><div class="productitemcell">Champagne Weadding</div></td>
          <td><div class="productitemcell">1 line custom</div></td>
        </tr>
      </tbody>
    </table>

    Code:
    function displaymessageNow()
    {
    var divArray = document.getElementsByClassName("productitemcell");
    
    for (var i = 0; i<divArray.length; i++)
    {
    if (divArray[i].class="productitemcell")
    alert(divArray[i].innerHTML);
    }
    }
    displaymessageNow();
    But this is obviously not the final result we are after.

    We need to be able to find the words "1 line custom" in the background (so the user dosnt see this happening) then once these words are found display a link.

    Let me know if this is making any sense to you.

    Thanks

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,681
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by broadbeach media View Post
    We need to be able to find the words "1 line custom" in the background (so the user dosnt see this happening) then once these words are found display a link.

    Let me know if this is making any sense to you.
    You want to find text and change that text to a link, so if the text was spider on a page called "fear of spiders" you would change the word "spider" to a link advertising spider cages?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

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