Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 06-13-2009, 03:35 AM Help please!
Super Talker

Posts: 132
Trades: 0
I'm sort of stumbling around through the dark with this but I have these three divs which are going to collapse and expand on click.

Code:
<div id="work">
    <h1>WORK</h1>
    
    <div class="top">
        <h1>Affluent Practice Marketing</h1>
        <img onclick="arrowChange()" class="arrow" id="arrowImg0" src="images/arrowDown.png" alt="" />
    <div class="clear"></div>
    </div>
    <div id="sec0" class="sec">
        <img src="images/ss-apm.jpg" alt="" />
    </div><!-- end sec -->
    
    <div class="top">
        <h1>Affluent Practice Marketing</h1>
        <img onclick="arrowChange()" class="arrow" id="arrowImg1" src="images/arrowDown.png" alt="" />
    <div class="clear"></div>
    </div>
    <div id="sec1" class="sec">
        <img src="images/ss-apm.jpg" alt="" />
    </div><!-- end sec -->
    
    <div class="top">
        <h1>Affluent Practice Marketing</h1>
        <img onclick="arrowChange()" class="arrow" id="arrowImg2" src="images/arrowDown.png" alt="" />
    <div class="clear"></div>
    </div>
    <div id="sec2" class="sec">
        <img src="images/ss-apm.jpg" alt="" />
    </div><!-- end sec -->
    
</div><!-- end work -->

Then I have this Javascript (which I'm still new to).

Code:
function arrowChange() {
    for (i=0;i < 3; i++) {
        var arrow = new Array();
        arrow[0] = document.getElementById('arrowImg' + i);
        arrow[1] = document.getElementById('arrowImg' + i);
        arrow[2] = document.getElementById('arrowImg' + i);
        
        var sec = new Array();
        sec[0] = document.getElementById('sec' + i);
        sec[1] = document.getElementById('sec' + i);
        sec[2] = document.getElementById('sec' + i);
    }
    alert(sec);
    if(arrow.src == 'http://localhost/owen/v2/images/arrowDown.png') {
        arrow.src = 'images/arrow.png';
        sec.style.padding = "0";
        sec.style.height = "0px";
    }else {
        arrow.src = 'images/arrowDown.png';
        sec.style.height = "auto";
        sec.style.padding = "15px";
    }
}
The basic function of the javascript is to have the arrows change source, obviously and to have the "sec" divs collapse and expand. (I have yet to attempt to add animation to them).

If anybody needs clarification on anything let me know. It should be pretty simple but I'm obviously doing something wrong. I can achieve this effect with only one div and I could do it by making a bunch of different functions but I am going for not having to make different functions and actually utilizing javascript, hence the for loop. But it doesn't work, so please help!

Thanks!
soap is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Help please!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.08098 seconds with 12 queries