PDA

View Full Version : tooltip dynamicly change image src



baggs1981
08-31-2011, 11:00 AM
1) Script Title: Image w/ description tooltip v2.0

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/imagetooltip.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.



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.

jscheuer1
08-31-2011, 11:38 AM
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:


document.getElementById('imgtip1').getElementsByTagName('img')[0].src

So I'm thinking something like:


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;

baggs1981
08-31-2011, 01:18 PM
Wicked that did it, thanks a lot :)