View Full Version : ONCLICK ..... display new image in specific DIV

Paul Williams
12-08-2011, 08:53 PM
from my spry sub.menu tab,
i'm trying to use "onclick" to post a new img in a specific div elsewhere on the page.

<li><a class="MenuBarItemSubmenu" href="#">CPQC</a>
<li><a href="#" onclick="document.getElementById('cpqcRange').src='images/cpqc/cpqcHot.png';">Hot</a></li>

<div id="cpqcRange">
<img src="cpqcLocation.png" alt="cpqcLocation" name="cpqcLocation" width="504" height="360" id="cpqcLocation" />

i think i'm close, but something is wrong.
can you just call up the div "cpqcRange" by name and slap a new img.src in there???????


today's weather in Kalispell, MT, USA
cold, brrrrr, not much snow, but it's coming soon
it was about 18degF this morning

12-09-2011, 06:51 AM
Change the id to the img:

<a href="#" onclick="document.getElementById('cpqcRange').src='mages/cpqc/cpqcHot.png';">Hot</a>

<div >
<img id="cpqcRange" src="cpqcLocation.png" alt="cpqcLocation" name="cpqcLocation" width="140" height="240" id="cpqcLocation" />

Paul Williams
12-09-2011, 09:53 PM
thank you Sunfighter,

it worked great !!!!