Web Design and Development Forums

Show/Hide Div + change image=HELP

This is a discussion on "Show/Hide Div + change image=HELP" within the JavaScript Forum section. This forum, and the thread "Show/Hide Div + change image=HELP are both part of the Program Your Website category.


Go Back   Webforumz.com > Program Your Website > JavaScript Forum

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old May 5th, 2008, 15:36   #1 (permalink)
New Member
 
Join Date: May 2008
Location: Amsterdam
Posts: 4
Show/Hide Div + change image=HELP

Hi There I have written a script that should do the following:

1- Click on add.png that changes in the minus.png , opens a hidden DIV with text and changes a photo all at the same time.
2- When then the delete.png is clicked everything has to go back to the original situation.

What does not work:
1- the add.png does not change into delete.png
2- the photo does not reset to the original one when the div is closed.

Here is my code:


Code: Select all
<script language="Javascript 1.2" type="text/javascript">
function show(id)

{
    el = document.getElementById(id);
    if (el.style.display == 'none')
    {
        el.style.display = '';
        el = document.getElementById('more' + id);
        el.innerHTML.thisImage = 'images/add.png';
    } else {
        el.style.display = 'none';
        el = document.getElementById('more' + id);
        el.innerHTML.thisImage = 'images/delete.png';
    }
}

function change_pic(val) {
    document.getElementById('image_name').src = val;

}

</script>
Here is the HTML

HTML: Select all
 <div class="foto">
<img name="image_name" id="image_name" src="../images/AllCd.jpg"  border="0" alt="i">
</div>


<p><strong> Olthuis</strong>
<a id="moreinfo" href="# " onclick="javascript:show('info'), change_pic('../images/Olthuis.jpg'); return false;">
<img src="add.png" ></a></p>
<div id="info" style="display: none">
BLABLABLA text
</div>
<p><strong>Teddy </strong> - 
<a id="moreinfo2" href="#" onclick="javascript:show('info2'), change_pic('../images/teddy.jpg'); return false;">
<img src=".add.png" ></a></p>
<div id="info2" style="display: none">
BLABLABLA text
</div>
<p><strong>Hermr</strong>
<a id="moreinfo3" href="#" onclick="javascript:show('info3'), change_pic('../images/ermine.jpg'); return false;">
<img src="add.png" ></a></p>
<div id="info3" style="display: none">
BLABLABLA text
</div></div></div>
THANK YOU!

Last edited by aso186; May 5th, 2008 at 20:09.
Webill is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 5th, 2008, 20:40   #2 (permalink)
Nerdy Moderator
 
CloudedVision's Avatar
 
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 520
Blog Entries: 4
Re: Show/Hide Div + change image=HELP

Little mysterious script here

Code: Select all
el.innerHTML.thisImage = 'images/add.png';
innerHTML will return the HTML contents of an element (a string), so adding .thisImage to a string will return nothing. You want something like this:

Code: Select all
document.getElementById('image_id').src = 'mysrc.gif';
__________________
Take it easy

Other Road Design

WebForumz Moderator: HTML | Javascript | PHP
CloudedVision is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 11th, 2008, 11:23   #3 (permalink)
New Member
 
Join Date: May 2008
Location: Amsterdam
Posts: 4
Re: Show/Hide Div + change image=HELP

Thank you. Indeed my code is not right.

What I actually want is that when I click on an icon the related div opens up (with text) and a photo changes in another place in the page.
When I close the div the text hides & the photo resets to its original.
I have a total of 4 divs and 5 photos (the original photo + the 4 related to the divs).

Hope this is clearer and that ou can help.
Chears
Webill is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 11th, 2008, 15:08   #4 (permalink)
Nerdy Moderator
 
CloudedVision's Avatar
 
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 520
Blog Entries: 4
Re: Show/Hide Div + change image=HELP

just use do something along the lines of this:

Code: Select all
el.innerHTML = '<p>Text!</p><img src="bla.gif" alt="Image!" />';
Hope that helps
__________________
Take it easy

Other Road Design

WebForumz Moderator: HTML | Javascript | PHP
CloudedVision is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS Show Hide with JS abis123 JavaScript Forum 4 Dec 13th, 2007 05:39
[SOLVED] Show&amp;Hide Div Box Maska JavaScript Forum 6 Oct 1st, 2007 11:04
Show/Hide JS pa007 JavaScript Forum 0 Apr 6th, 2007 19:18
Show and Hide Text - how do I do that? Love2Java JavaScript Forum 1 Mar 29th, 2007 00:23
Show/Hide Div Help Trebz JavaScript Forum 2 Feb 21st, 2006 22:37



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 19:21.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59