BetaONE will rise again!


Reply
  #1  
Old 28th Sep 06, 08:35 AM
*MO*'s Avatar
*MO* *MO* is offline
Senior Member
 
Join Date: Aug 2002
Location: Cape Town
Posts: 311
*MO* is an unknown quantity at this point
Send a message via MSN to *MO*
Javascript slide
Good day everyone

I've got a small javascript problem. if you have a look on my site, http://www.entersite.co.za, you'll see there are 2 links on the left. Gallery 1 and Gallery 2. When you click either one, the right side panel will expand.

eg : Click Gallery 2, right side will expand with gallery 2 pictures. When I click gallery one, it will collapse, and then I have to click it again to expand the right side with pics from gallery 1.

I want it, so that when I click gallery 1, that the panel will shrink, and then expand again to show pics from gallery 1.

any help would be great. or an example of a script that does this will also help.

I'm not using divs or layers. I'm just using a script that increases the <td> height.

Code:
<script language="JavaScript" type="text/javascript"> var resizeIntervalId = null; function startResize(id, height) { clearInterval(resizeIntervalId); resizeIntervalId = setInterval("resize('" + id + "', " + height + ");",1); } function slide(id) { var element = document.getElementById(id); if(parseInt(element.style.height) == 100) { startResize(id, 0); if(parseInt(element.style.height) <= 90) { alert("here"); startResize(id, 100); } } else { startResize(id, 100); } } function resize(id, height) { var element = document.getElementById(id); var nextSize; if(parseInt(element.style.height) == height) { clearInterval(resizeIntervalId); return; } else if(parseInt(element.style.height) > height) { nextSize = parseInt(element.style.height) - 10; } else { nextSize = parseInt(element.style.height) + 10; } element.style.height = nextSize + "px"; if((parseInt(element.style.height) == height)&&(parseInt(element.style.height) > 1)) { document.getElementById("imageGallery").innerHTML = "Test" } else { document.getElementById("imageGallery").innerHTML = "" } } </script> <table> <td> <a href="#" onClick="javascript:slide('slider');">Gallery 1</a> <br> <a href="#" onClick="javascript:slide('slider');">Gallery 2</a> </td> <Td id="slider" style="width:100px; height:0px; background-color:white;" nowrap> <div id="imageGallery"></div> </TD> </table>
any help would be great. Thanx
Reply With Quote
  #2  
Old 15th Oct 06, 07:48 PM
robinwilson16 robinwilson16 is offline
Administrator
 
Join Date: Jul 2001
Location: UK
Posts: 903
robinwilson16 will become famous soon enoughrobinwilson16 will become famous soon enough
Fixed it for you

It now differentiates between the galleries and displays different text depending upon which was clicked. It expands when you click a gallery and contracts if you click the same gallery again or if you clicked another gallery it contracts the old one then expands the new one.
The contents for each gallery can be modified at the top of the script.

Hope this is what you wanted.
Robin

Code:
<script language="JavaScript" type="text/javascript"> var gall1 = "Gallery 1 Content Here"; var gall2 = "Gallery 2 Content Here"; var curnum = 0; var resizeIntervalId = null; function startResize(id, height, num) { clearInterval(resizeIntervalId); resizeIntervalId = setInterval("resize('" + id + "', " + height + ", " + num + ");",1); } function slide(id, num) { var element = document.getElementById(id); if(parseInt(element.style.height) == 100) { startResize(id, 0, num); if(parseInt(element.style.height) <= 90) { startResize(id, 100, num); curnum = num; } } else { startResize(id, 100, num); curnum = num; } } function resize(id, height, num) { var element = document.getElementById(id); var nextSize; if(parseInt(element.style.height) == height) { if (curnum != num) { clearInterval(resizeIntervalId); startResize(id, 100, num); curnum = num; return; } else { clearInterval(resizeIntervalId); return; } } else if(parseInt(element.style.height) > height) { nextSize = parseInt(element.style.height) - 10; } else { nextSize = parseInt(element.style.height) + 10; } element.style.height = nextSize + "px"; if((parseInt(element.style.height) == height)&&(parseInt(element.style.height) > 1)&&(num == 1)) { document.getElementById("imageGallery").innerHTML = gall1 } else if((parseInt(element.style.height) == height)&&(parseInt(element.style.height) > 1)&&(num == 2)) { document.getElementById("imageGallery").innerHTML = gall2 } else { document.getElementById("imageGallery").innerHTML = "" } } </script> <table width="100%" align="left"> <td width="100"> <a href="#" onClick="javascript:slide('slider', 1);">Gallery 1</a> <br> <a href="#" onClick="javascript:slide('slider', 2);">Gallery 2</a> </td> <Td id="slider" style="width:100px; height:0px; background-color:white;" nowrap> <div id="imageGallery"></div> </TD> </table>
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Music sales slide despite RIAA's best efforts NewsBot NeoWin News 1 4th Jan 06 12:03 AM
Firefox javascript vulnerability discovered NewsBot ieXbeta News 0 5th Apr 05 04:00 PM


All times are GMT +1. The time now is 05:15 PM.


Design by Vjacheslav Trushkin for phpBBStyles.com.
Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.