Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2008
    Location
    MD, USA
    Posts
    65
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Simple CSS rollovers disappearing & inconsistent when combined with JS

    I'm using two simple CSS rollovers for a prev/next arrow nav, combined with a JS script that lets the user manually tab/flip/swap through a few testimonials. You roll over the "next" button, it's highlighted, you click it, a new testimonial appears in place of the old one.

    Problem: the prev/next buttons are appearing and disappearing on click, seemingly randomly. I can't make any sense of it.

    Image: http://img3.imageshack.us/img3/8924/jsproblem.jpg

    I've tried adjusting the CSS container sizes, tried changing the positioning and even adding z-indexes in case the divs are accidentally overlapping. Gave items background colors to try to see the structure more clearly, for flaws. Nothing has worked.

    Any help much appreciated.

    I'm using this JS script for the tabs:

    Code:
    last_tab = 'tabTest1';
        function show(layerName) { 
        document.getElementById(layerName).style.display = '';}
        function hide(layerName) { 
        document.getElementById(layerName).style.display = 'none';}
        function show_next(tab_name) {
        document.getElementById(last_tab).className = '';
        var curr = document.getElementById(tab_name);
        curr.className='';
        hide(last_tab+'_data');
        show(tab_name+'_data');
        last_tab=tab_name;}
    and this HTML:

    Code:
    
            <!-- start: testimonials -->
            <div id="tabTest1_data">
                <div class="silo1">
                    <div class="spotlightnav-content-header-container">
                        <p class="spotlightnav-content-title">Testimonials</p>
                        <a href="#" class="spotlightnav-content-more">View All</a>
                    </div>
    
                    <div class="content-container">
                        <p class="spotlightnav-testimonials">
                        	<span class="color1">"</span>Excellent staff very courteous, friendly and professional, excellent stay, excellent meal.<span class="color1">"</span>
                        </p>
                        <p class="spotlightnav-testimonials-credit">Janice, Georgia</p>
                    </div>
                    
                    <div class="spolightnav-btns-container">
                        <a href="#" onClick="javascript:show_next('tabTest6'); return false;" id="tabTest6" class="spotlightnav-btn-left"><img src="images/clear.gif" width="24" height="24" /></a>
                        <a href="#" onClick="javascript:show_next('tabTest2'); return false;" id="tabTest2" class="spotlightnav-btn-right"><img src="images/clear.gif" width="24" height="24" /></a>
              		</div>
                 </div>
    		</div>
            
            <div id="tabTest2_data" style="display: none;">
                <div class="silo1">
                    <div class="spotlightnav-content-header-container">
                        <a href="#" class="spotlightnav-content-title">Testimonials</a>
                        <a href="#" class="spotlightnav-content-more">View All</a>
                    </div>
    
                    <div class="content-container">
                        <p class="spotlightnav-testimonials">
                        <span class="color1">"</span>Absolutely marvelous. No problems.<span class="color1">"</span>
                        </p>
                        <p class="spotlightnav-testimonials-credit">Christine, Taiwan</p>
                    </div>
    
                    <div class="spolightnav-btns-container">
                        <a href="#" onClick="javascript:show_next('tabTest1'); return false;" id="tabTest1" class="spotlightnav-btn-left"><img src="images/clear.gif" width="24" height="24" style="height: 24px; width: 24px;" /></a>
                        <a href="#" onClick="javascript:show_next('tabTest3'); return false;" id="tabTest3" class="spotlightnav-btn-right"><img src="images/clear.gif" width="24" height="24" style="height: 24px; width: 24px;" /></a>                </div>
            	</div>
    		</div>
            
            <div id="tabTest3_data" style="display: none;">
                <div class="silo1">
                    <div class="spotlightnav-content-header-container">
                        <a href="#" class="spotlightnav-content-title">Testimonials</a>
                        <a href="#" class="spotlightnav-content-more">View All</a>
                    </div>
    
                    <div class="content-container">
                        <p class="spotlightnav-testimonials">
                        <span class="color1">"</span>Absolutely marvelous. No problems.<span class="color1">"</span>
                        </p>
                        <p class="spotlightnav-testimonials-credit">Belle, Taiwan</p>
                    </div>
                    
                    <div class="spolightnav-btns-container">
                        <a href="#" onClick="javascript:show_next('tabTest2'); return false;" id="tabTest2" class="spotlightnav-btn-left"><img src="images/clear.gif" width="24" height="24" /></a>
                        <a href="#" onClick="javascript:show_next('tabTest4'); return false;" id="tabTest4" class="spotlightnav-btn-right"><img src="images/clear.gif" width="24" height="24" /></a>                </div>
            	</div>
    		</div>
            
            <div id="tabTest4_data" style="display: none;">
                <div class="silo1">
                    <div class="spotlightnav-content-header-container">
                        <a href="#" class="spotlightnav-content-title">Testimonials</a>
                        <a href="#" class="spotlightnav-content-more">View All</a>
                    </div>
    
                    <div class="content-container">
                        <p class="spotlightnav-testimonials">
                        <span class="color1">"</span>Vaguely not-terrible. Acceptable in a somewhat amazing way. ffffffffuuuuuuuuu<span class="color1">"</span>
                        </p>
                        <p class="spotlightnav-testimonials-credit">Grace, Texas</p>
                    </div>
    
                    <div class="spolightnav-btns-container">
                        <a href="#" onClick="javascript:show_next('tabTest3'); return false;" id="tabTest3" class="spotlightnav-btn-left"><img src="images/clear.gif" width="24" height="24" /></a>
                        <a href="#" onClick="javascript:show_next('tabTest5'); return false;" id="tabTest5" class="spotlightnav-btn-right"><img src="images/clear.gif" width="24" height="24" /></a>                </div>
            	</div>
    		</div>
            
            <div id="tabTest5_data" style="display: none;">
                <div class="silo1">
                    <div class="spotlightnav-content-header-container">
                        <a href="#" class="spotlightnav-content-title">Testimonials</a>
                        <a href="#" class="spotlightnav-content-more">View All</a>
                    </div>
    
                    <div class="content-container">
                        <p class="spotlightnav-testimonials">
                        <span class="color1">"</span>Damn fine place, yo.<span class="color1">"</span>
                        </p>
                        <p class="spotlightnav-testimonials-credit">Slim, Bacon</p>
                    </div>
                    
                    <div class="spolightnav-btns-container">
                        <a href="#" onClick="javascript:show_next('tabTest4'); return false;" id="tabTest4" class="spotlightnav-btn-left"><img src="images/clear.gif" width="24" height="24" /></a>
                        <a href="#" onClick="javascript:show_next('tabTest6'); return false;" id="tabTest6" class="spotlightnav-btn-right"><img src="images/clear.gif" width="24" height="24" /></a>                </div>
            	</div>
    		</div>
            
            <div id="tabTest6_data" style="display: none;">
                <div class="silo1">
                    <div class="spotlightnav-content-header-container">
                        <a href="#" class="spotlightnav-content-title">Testimonials</a>
                        <a href="#" class="spotlightnav-content-more">View All</a>
                    </div>
    
                    <div class="content-container">
                        <p class="spotlightnav-testimonials">
                        <span class="color1">"</span>Blurry. But good.<span class="color1">"</span>
                        </p>
                        <p class="spotlightnav-testimonials-credit">Bob, California</p>
                    </div>
    
                    <div class="spolightnav-btns-container">
                        <a href="#" onClick="javascript:show_next('tabTest5'); return false;" id="tabTest5" class="spotlightnav-btn-left"><img src="images/clear.gif" width="24" height="24" /></a>
                        <a href="#" onClick="javascript:show_next('tabTest1'); return false;" id="tabTest1" class="spotlightnav-btn-right"><img src="images/clear.gif" width="24" height="24" /></a>                </div>
            	</div>
    		</div>
    I'm assuming this is primarily a JS problem, but if taking a look at the CSS is necessary, let me know and I'll post it.

    THANKS!!!!!

  • #2
    New Coder
    Join Date
    Nov 2009
    Posts
    31
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I am guessing that you are trying to cycle through all the available tabs? If so this is called a "wizard" among other things. The "tab" metaphor is irrelevant.

    So, to clarify, you would like the "back" and "next" buttons to cycle to the end with (next) and to the beginning with (back). You would like the appropriate button to disappear if it hits the end or beginning. This will let your users know when they have reached the limit of "next" or "back".

    Is this correct?


    Assuming this is correct you will need an "index" of some sort to track the available items as you cycle. I will wait to make sure I am correct before posting the rest.

  • #3
    New Coder
    Join Date
    Jul 2008
    Location
    MD, USA
    Posts
    65
    Thanks
    16
    Thanked 0 Times in 0 Posts
    Thanks for responding. No, that's not correct - having the button disappear when the cycle reaches the end is not a necessary function in this case.

    They're testimonials from customers, so there's no particular order in which they should be... therefore, when the user hits the "end" of the cycle going forward (say, he gets to testimonial #6), the cycle should just start over again (from #6 to #1).

    The problem is that the buttons keep disappearing and appearing with no rhyme or reason. They show up on testimonial #1, then I click the "next" button, and on testimonial #2, only the "next" button shows (not the prev). I click it, go to testimonial #3, and both buttons show, as they should. Same with #4, #5, #6... and then when I click from #6 back to #1, this time BOTH buttons have disappeared. I can still click the area, but the images themselves are gone. They appear and disappear randomly from there on out. I can't figure it out for the life of me.

    Thanks for any help!


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •