www.webdeveloper.com
Results 1 to 2 of 2

Thread: Tab Panels Code Problem- Please Help!

  1. #1
    Join Date
    Oct 2009
    Posts
    5

    Tab Panels Code Problem- Please Help!

    Hi Y'all...

    I am hoping that someone can help me fix some pretty simple code.

    I am building a web page that has tab panels that hide and show information depending on which one is selected. I am trying to make horizontal tabs at the top of the page.

    I have had some success, however I am having two problems:

    The first problem is that one of the tabs doesn't work (specifically tab 4 "videos").

    The other is that when you first start up the page, there are three tabs highlighted (1, 4 and 5), however there should only be 1 tab highlighted (tab1).

    I have included my code below. Can anyone tell me where my mistakes are?

    Thank you!!!



    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script type="text/javascript" language="JavaScript"><!--
    function ManageTabPanelDisplay() {

    var idlist = new Array('tab1focus','tab2focus','tab3focus','tab4focus', 'tab5focus','tab1ready','tab2ready','tab3ready','tab4ready', 'tab5ready','content1','content2','content3','content4','content5');

    // No other customizations are necessary.
    if(arguments.length < 1) { return; }
    for(var i = 0; i < idlist.length; i++) {
    var block = false;
    for(var ii = 0; ii < arguments.length; ii++) {
    if(idlist[i] == arguments[ii]) {
    block = true;
    break;
    }
    }
    if(block) { document.getElementById(idlist[i]).style.display = "block"; }
    else { document.getElementById(idlist[i]).style.display = "none"; }
    }
    }
    //--></script>


    <style type="text/css">
    .tab {
    font-family: verdana,sans-serif;
    font-size: 14px;
    width: 100px;
    white-space: nowrap;
    text-align: center;
    border-style: solid;
    border-color: black;
    border-left-width: 1px;
    border-right-width: 1px;
    border-top-width: 1px;
    border-bottom-width: 0px;
    padding-top: 5px;
    padding-bottom: 5px;
    cursor: pointer;
    }
    .tabhold {
    background-color: white;
    color: black;
    }
    .tabfocus {
    background-color: black;
    color: white;
    }
    .tabcontent {
    font-family: sans-serif;
    font-size: 14px;
    width: 580px;
    height: 275px;
    border-style: solid;
    border-color: black;
    border-width: 1px;
    padding-top: 15px;
    padding-left: 10px;
    padding-right: 10px;
    }
    </style>


    </head>

    <body>
    <table border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td>
    <div id="tab1focus" class="tab tabfocus" style="display:block;">Description</div>
    <div id="tab1ready" class="tab tabhold" style="display:none;">
    <span onclick="ManageTabPanelDisplay('tab1focus','tab2ready','tab3ready','tab4ready','tab5ready','content1 ')">Description</span>
    </div>
    </td><td width="20"> </td>


    <td>
    <div id="tab2focus" class="tab tabfocus" style="display:none;">
    Images
    </div>
    <div id="tab2ready" class="tab tabhold" style="display:block;">
    <span onclick="ManageTabPanelDisplay('tab1ready','tab2focus','tab3ready','content2','tab4ready','tab5ready ')">Images</span>
    </div>
    </td><td width="20"> </td>


    <td>
    <div id="tab3focus" class="tab tabfocus" style="display:none;">
    Specifications
    </div>
    <div id="tab3ready" class="tab tabhold" style="display:block;">
    <span onclick="ManageTabPanelDisplay('tab1ready','tab2ready','tab3focus','content3','tab4ready','tab5ready ')">Specifications</span>
    </div>
    </td><td width="20"> </td>

    <td>
    <div id="tab4focus" class="tab tabfocus" style="display:block;">
    Videos
    </div>
    <div id="tab4ready" class="tab tabhold" style="display:none;">
    <span onclick="ManageTabPanelDisplay('tab1ready','tab2ready','tab3ready','tab4focus','content4',tab5ready' )">Videos</span>
    </div>
    </td><td width="20"> </td>

    <td>
    <div id="tab5focus" class="tab tabfocus" style="display:block;">
    Pricing
    </div>
    <div id="tab5ready" class="tab tabhold" style="display:none;">
    <span onclick="ManageTabPanelDisplay('tab1ready','tab2ready','tab3ready','tab4ready','content5','tab5focus ')">Pricing</span>
    </div>
    </td>


    </tr>

    <tr>
    <td colspan="9">

    <div id="content1" class="tabcontent" style="display:block;">
    <p>
    This is where descriptions go!
    </p>
    </div>

    <div id="content2" class="tabcontent" style="display:none;">
    <p>
    This is where images go.
    </p>
    </div>

    <div id="content3" class="tabcontent" style="display:none;">
    <p>
    This is where specs go!
    </p>
    </div>

    <div id="content4" class="tabcontent" style="display:none;">
    <p>
    This is where videos go!
    </p>
    </div>

    <div id="content5" class="tabcontent" style="display:none;">
    <p>
    This is where pricing goes.
    </p>
    </div>

    </td></tr>
    </table>
    </body>
    </html>

  2. #2
    Join Date
    Jan 2009
    Location
    Ohio
    Posts
    3,356
    Code:
    <div id="tab4ready" class="tab tabhold" style="display:none;">
    <span onclick="ManageTabPanelDisplay('tab1ready','tab2ready','tab3ready','tab4focus','content4','tab5ready' )">Videos</span>
    </div>
    I couldn't see what is wrong with your other code at first glance. Do you have a live link to look at? Also please use the appropriate tags for code so it is easier to look at. Additionally, this is a javascript issue not an HTML one, please post to the appropriate forum next time (since you are more likely to get a quicker response).

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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
  •  
HTML5 Development Center

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.10973 seconds
  • Memory Usage 2,849KB
  • Queries Executed 13 (?)
More Information
Template Usage (33):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (2)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (71):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates