SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onhover text for on images using javascript

    i found this tutorial on the internet for hovering for a navagation and thought i attepmt to re-create it for placing on images the only problem is the javascript code is not displaying the text when you hover over the image here is the code i have being echoed using php

    PHP Code:
    echo "<img src=".$data['image']." width=\"100px\" height=\"100px\"
                         onMouseover=\"showtext('
    $awarder awarded the $medal for $reason on $date!')" onMouseout=\"hidetext()>"
    and for the actual javascript coding this is what i have.

    HTML Code:
    function showtext(thetext){
    if (!document.getElementById)
    return
    textcontainerobj=document.getElementById("tabledescription")
    browserdetect=textcontainerobj.filters? "ie" : typeof textcontainerobj.style.MozOpacity=="string"? "mozilla" : ""
    instantset(baseopacity)
    document.getElementById("tabledescription").innerHTML=thetext
    highlighting=setInterval("gradualfade(textcontainerobj)",50)
    }
    
    function hidetext(){
    cleartimer()
    instantset(baseopacity)
    }
    im not sure why its not working but that is what im wanting for it to display is a little screen popping up saying when the person has been awarded this why and the date which is all stored in a database.

    How can i get this to be fixed?

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    I don't think that some of the quotes in the php code are being properly escaped.
    What does the source code (after being rendered by php) show for the image?

    There are also other things that the script relies on, which you haven't mentioned or shown the code for. For example, an element with an id of "tabledescription" and the functions instantset() and gradualfade(), and the variable baseopacity

    Where did you find that tutorial?
    Last edited by paul_wilkins; Dec 26, 2008 at 14:49.
    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
  •