Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-08-2011, 07:50 PM   PM User | #1
Paul Williams
New Coder

 
Join Date: Dec 2011
Posts: 59
Thanks: 51
Thanked 1 Time in 1 Post
Paul Williams is an unknown quantity at this point
ONCLICK....post new image in DIV

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>
<ul>
<li><a href="#" onclick="document.getElementById('cpqcRange').src='images/cpqc/cpqcHot.png';">Hot</a></li>
</ul>
</li>

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

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???????

cheers,
Paul

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

Last edited by Paul Williams; 12-09-2011 at 02:50 AM..
Paul Williams is offline   Reply With Quote
Old 12-08-2011, 08:08 PM   PM User | #2
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello Paul Williams,
Maybe this simple js switcher would work for you - http://nopeople.com/CSS%20tips/new_e...her/index.html

You are colder in Kalispell than we are in Palmer today.
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Old 12-08-2011, 08:15 PM   PM User | #3
teedoff
Senior Coder

 
Join Date: Aug 2010
Location: High Point, NC
Posts: 3,325
Thanks: 5
Thanked 363 Times in 360 Posts
teedoff is on a distinguished road
Hi Paul, welcome.

Yeah thats gonna take some javascript. Anytime you want something in a webpage to "change" it will take something other than static html, which is very limited.

Since you just finished that Missing Manual book, WOW btw! lol

You should look into the built in snippets panel in DW where you can find lots of javascript code snippets.
__________________
Teed
teedoff is offline   Reply With Quote
Old 12-08-2011, 11:21 PM   PM User | #4
Paul Williams
New Coder

 
Join Date: Dec 2011
Posts: 59
Thanks: 51
Thanked 1 Time in 1 Post
Paul Williams is an unknown quantity at this point
thanks Excavator, i'll check out the link

thanks Teedoff, i'll check into the snippets and start boning up on javascript.
i did find "showimage()" in javascript, but will have to chase it down and study the sintax.
Paul Williams is offline   Reply With Quote
Old 12-09-2011, 04:21 PM   PM User | #5
mvmacd
New Coder

 
Join Date: Nov 2011
Location: New England
Posts: 62
Thanks: 0
Thanked 10 Times in 10 Posts
mvmacd is an unknown quantity at this point
Quote:
Originally Posted by Paul Williams View Post
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>
<ul>
<li><a href="#" onclick="document.getElementById('cpqcRange').src='images/cpqc/cpqcHot.png';">Hot</a></li>
</ul>
</li>

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

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???????

cheers,
Paul

today's weather in Kalispell, MT, USA
cold, brrrrr, not much snow, but it's coming soon
it was about 18degF this morning
So when you click on something, you want to add a new image to a div?

Add jQuery to your page and try this:

Code:
<script type='text/javascript'>
$(document).ready(function () 
{ 

$('#TRIGGER').click(function () //change TRIGGER to the ID of the link.  Or you can make below this a function and call it with onclick
{
$('#cpqcRange').append("<img src='/path/to/image.jpg'>");
});


});
</script>
Easy as that. That will append the text to the end of the div that has the ID is cpqcRange.

If you want to change the src of an image already there:
Code:
$('#image').attr('src','/path/to/image.jpg');
__________________
For programming information, visit irnsystems.com
Also check out Points2Survey and earn items.

Last edited by mvmacd; 12-09-2011 at 04:23 PM.. Reason: code fix
mvmacd is offline   Reply With Quote
Users who have thanked mvmacd for this post:
Paul Williams (12-09-2011)
Old 12-09-2011, 08:56 PM   PM User | #6
Paul Williams
New Coder

 
Join Date: Dec 2011
Posts: 59
Thanks: 51
Thanked 1 Time in 1 Post
Paul Williams is an unknown quantity at this point
thank you Mvmacd

got it worked out.

Paul Williams is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:19 PM.


Advertisement
Log in to turn off these ads.