WordPress.org

Ready to get started?Download WordPress

Forums

Will not work as I need it to. (1 post)

  1. tenkabuto
    Member
    Posted 6 years ago #

    I'm trying to add a tab system to the sidebar of my WordPress theme, but it will not work as it should. I have the tab code from a previous project which works fine and I've edited it slightly for this, but it just will not work. Below is the code I have so far in the sidebar of my theme (this is only the tab part):

    <script type="text/javascript">function show_hide(my_id, my_id2) {
    
    	document.getElementById('content1').style.display = 'none';
    	document.getElementById('content2').style.display = 'none';
    	document.getElementById('content3').style.display = 'none';
    	document.getElementById(my_id).style.display = 'block';		
    
    	document.getElementById('link1').className = 'show_hide';
    	document.getElementById('link2').className = 'show_hide';
    	document.getElementById('link3').className = 'show_hide';
    	document.getElementById(my_id2).className = 'show_hide_down';		
    
    }</script>
    <h2><?php if (function_exists('get_recent_comments')) { ?><a href="javascript:show_hide('content1', 'link1');" class="show_hide_down" id="link1"><?php _e('Recent Comments'); ?></a><?php } ?> <?php if (is_user_logged_in()){ ?><a href="javascript:show_hide('content2', 'link2');" class="show_hide" id="link2">SayBox</a><?php } ?> <a href="javascript:show_hide('content3', 'link3');" class="show_hide" id="link3">Random Posts</a></h2>
    <?php if (function_exists('get_recent_comments')) { ?>
    <div id="content1" style="display:none;">
       <li>
       <ul class="item_list" id="recent_comments"><?php get_recent_comments(); ?></ul>
       </li>
      </div>
    <script>
    var cols = ["blah1", "blah2", "blah3"];
    
    var n = document.getElementById("recent_comments"), li = n.getElementsByTagName("li"), b=-1;
    while(li[++b]){
    	li[b].className = cols[b%cols.length]
    }</script>
    <style>#sidebar ul#recent_comments li {padding: 4px;}
    #sidebar ul#recent_comments li.blah1 {background-color: #DDD;}
    #sidebar ul#recent_comments li.blah2 {background-color: #EEE;}
    #sidebar ul#recent_comments li.blah3 {background-color: #DFDFDF;}</style>
    <?php } ?>
    <?php if (is_user_logged_in()){ ?><div id="content2" style="display:none;">
    <script type="text/javascript" src="http://saybox3.co.uk/output.php?user=tenkabuto"></script>
      </div><?php } ?>

    You can see it on my site, here.

Topic Closed

This topic has been closed to new replies.

About this Topic