Results 1 to 3 of 3

Thread: tooltip dynamicly change image src

  1. #1
    Join Date
    Aug 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default tooltip dynamicly change image src

    1) Script Title: Image w/ description tooltip v2.0

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...agetooltip.htm

    3) Describe problem: I have implimented this and it is working great, however, what I would like to do is to change one of the tooltip images depending on the text entered in a textbox which obviously happens after the page has loaded all the tooltips already. I am trying the below which I hope gives an idea of what I want to do.


    Code:
    window.sLink="http://intranet/TelephoneDirectory/Handler/GetImage.ashx?ID=";
    window.sParm="&S=LLP&W=50";
    imgtip1.src = sLink + IDNow + sParm;
    It doesn't give any errors but also doesn't alter the src of the tooltip image. In the Tooltip array it is number 1 which I want to change the source image for dynamically.

    If any ideas please let me know, someone asked a similary question already but there is no suggestions on that post yet.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    In the code in your post, IDNow is undefined. It might be defined elsewhere, as it looks like it needs to be in order produce the desired URL + query/get combo.

    I'll let you work that out. As I say it may be defined elsewhere. Hopefully you understand what I mean. If not, let me know.

    The larger problem is that you want to access the src attribute of a tip's image. Once the script initializes, I see no way of doing so other than directly accessing the image element. In the case of the second tip (imgtip1 is the second tip, imgtip0 would be the first tip), for the second tip that would be:

    Code:
    document.getElementById('imgtip1').getElementsByTagName('img')[0].src
    So I'm thinking something like:

    Code:
    window.sLink="http://intranet/TelephoneDirectory/Handler/GetImage.ashx?ID=";
    window.sParm="&S=LLP&W=50";
    document.getElementById('imgtip1').getElementsByTagName('img')[0].src = sLink + IDNow + sParm;
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    baggs1981 (08-31-2011)

  4. #3
    Join Date
    Aug 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Wicked that did it, thanks a lot

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
  •