Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ho do I link .jpg colour to value in table ? 1

Status
Not open for further replies.

Recce

Programmer
Aug 28, 2002
425
ZA
Hi,

I am busy building a dashboard page and I need to link a .jpg to a value in a table or file. In other words, I would like to update or replace the .jpg with a different colour or replace the .jpg with a different .jpg when the value in the file changes.

I was thinking of making use of a case or IF statement which should replace the .jpg when the value changes.Have anyone got any ideas as to how I could do this or where I can go and have a look in order to get some ideas ?

[pipe] "We know nothing but, that what we know is not the truth..." - Me
 
...or where I can go and have a look in order to get some ideas ?

Google is always a good start. However, if all you're trying to do is swap out one image for another, all you have to do is change the src value for that particular <img> tag. Like so:
Code:
<script type="text/javascript">

[!]document.getElementById("myImg").src = "./images/someOtherImage.jpg";[/!]

</script>

<!-- assuming you have an image like this: -->

<img [!]id="myImg"[/!] src="./images/initialImage.jpg" alt="first image" />

-kaht

Looking for a puppy? [small](Silky Terriers are hypoallergenic dogs that make great indoor pets due to their lack of shedding and small size)[/small]
 
Brilliant idea this one and this was exactly what I was looking for. Thank you very much !

Regards

[pipe] "We know nothing but, that what we know is not the truth..." - Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top