943,840 Members | Top Members by Rank

Ad:
Jun 11th, 2008
0

photo and text swap

Expand Post »
I am trying to swap an image with 6 guys on a couch for each one sitting individual. And once the individual is showing, display their bio underneath. I can get the image to change and the text to show but when I roll to the next guy the text doesn't swap but overlaps. I am very new to Javascript so speak down to me, thanks

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <a onmouseover="javascript:showHide('jeff'); return showPic(this)" href="/images/group_jeff.jpg" class="560" name="357" >Jeff</a>

Each div of text starts with display:none
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <div id="jeff" style="display:none">

When I mouseover, the ShowHide displays the text, the return ShowPic shows the image but then I need that text to go away when I mouse off or mouse over the next person's name.

Thanks for your help!!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
designermom2 is offline Offline
4 posts
since Jun 2008
Jun 12th, 2008
0

Re: photo and text swap

Here are the 2 pieces of code

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. //Text Show/Hide
  2.  
  3. function showHide(elementid){
  4. if (document.getElementById(elementid).style.display == 'none'){
  5. document.getElementById(elementid).style.display = '';
  6. } else {
  7. document.getElementById(elementid).style.display = 'none';
  8. }
  9. }
  10.  
  11. // Image Swap
  12. function showPic (whichpic) {
  13. if (document.getElementById) {
  14. document.getElementById('placeholder').src = whichpic.href;
  15. document.getElementById('popuplink').href = whichpic.href;
  16. document.getElementById('popuplink').className = whichpic.className;
  17. document.getElementById('popuplink').name = whichpic.name;
  18. if (whichpic.title) {
  19. document.getElementById('placeholder').alt = whichpic.title;
  20. }
  21. return false;
  22. } else {
  23. return true;
  24. }
  25. }
Last edited by designermom2; Jun 12th, 2008 at 10:28 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
designermom2 is offline Offline
4 posts
since Jun 2008
Jun 13th, 2008
0

Re: photo and text swap

you can move these events out into a function, but im just keeping it simple.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <div onmouseover="document.getElementById('img1').style.display='block';document.getElementById('txt1').style.display='none';"
  2. onmouseleave="document.getElementById('txt1').style.display='block';document.getElementById('img1').style.display='none';">
  3. <img id="img1" src="img1.jpg" style="display: none;">
  4. <div id="txt1" style="display: block">
  5. text 1</div>
  6. </div>
Reputation Points: 23
Solved Threads: 16
Posting Whiz in Training
plazmo is offline Offline
206 posts
since Aug 2005
Jun 14th, 2008
0

Re: photo and text swap

Display has the attribute 'hidden', not 'none'.
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007
Jun 15th, 2008
0

Re: photo and text swap

Click to Expand / Collapse  Quote originally posted by MidiMagic ...
Display has the attribute 'hidden', not 'none'.
no, display:none is correct.
your thinking of visibility:hidden

and display:none is better then visibility:hidden because it actually collapses the element rather then just hiding it and leaving a big empty space.
Reputation Points: 23
Solved Threads: 16
Posting Whiz in Training
plazmo is offline Offline
206 posts
since Aug 2005
Jun 19th, 2008
0

Re: photo and text swap

Right.

Visibility also has a "collapse" property.

I thought you didn't want the structure to change.
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007
Jun 19th, 2008
0

Re: photo and text swap

Click to Expand / Collapse  Quote originally posted by MidiMagic ...
Right.

Visibility also has a "collapse" property.

I thought you didn't want the structure to change.
collapse is only useful for table rows or columns. otherwise its rendered as just hidden on any other element.
it wont change the structure if the text and the image are the same size.
Reputation Points: 23
Solved Threads: 16
Posting Whiz in Training
plazmo is offline Offline
206 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: block f5 functionality
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: automatically html page has to upload to live website





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC