Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9201127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:55:51+00:00 2026-06-17T22:55:51+00:00

I am trying to layout a web app. Each screen of my web app

  • 0

I am trying to layout a web app. Each screen of my web app is a panel. I have the following panels right now: home, about, settings, game, and results. I only want to display one panel at a time. Right now only the home panel should show but my code is not working (all panels are showing right now). What am I missing?

jsFiddle: http://jsfiddle.net/bNzVA/

<!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>
<style>
</style>
<script>
window.onload = myOnloadFunc;

function myOnloadFunc() {
    var homePanel = document.getElementById("homePanel");
    var aboutPanel = document.getElementById("aboutPanel");
    var settingsPanel = document.getElementById("settingsPanel");
    var gamePanel = document.getElementById("gamePanel");
    var resultsPanel = document.getElementById("resultsPanel");

    // All panels in app
    var panels = ["homePanel", "aboutPanel", "settingsPanel", "gamePanel", "resultsPanel"];

    // Show selected panel and hide all other panels
    function showPanel(panel) {
        for (var i = 0; i < panels.length; i++) {
            if (panel) {
                // Show panel
                this.style.display = "block";
            } else {
                // Hide
                this.style.display = "none";
            }
        }
    }

    showPanel("homePanel");
}
</script>
</head>

<body>
<!-- homePanel -->
<div class="panel" id="homePanel">
Home panel
</div>

<!-- aboutPanel -->
<div class="panel" id="aboutPanel">
About panel
</div>
</body>

<!-- settingsPanel -->
<div class="panel" id="settingsPanel">
Settings panel
</div>

<!-- gamePanel -->
<div class="panel" id="gamePanel">
Game panel
</div>

<!-- resultsPanel -->
<div class="panel" id="resultsPanel">
Results panel
</div>

</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:55:52+00:00Added an answer on June 17, 2026 at 10:55 pm

    You had a couple of issues in the code.

    1. this keyword. The way you used it referred to the global object, i.e. Window.
    2. iterated over panels but not assign it to anything.
    3. store nodes in panels
    4. compare panels nodes to the node you pass into showPanel

    I updated your fiddle: http://jsfiddle.net/bNzVA/2/

    // All panels in app
    var panels = [homePanel, aboutPanel, settingsPanel, gamePanel, resultsPanel];
    
    // Show selected panel and hide all other panels
    function showPanel(panel) {
        for (var i = 0; i < panels.length; i++) {
            var p = panels[i]
            if (p === panel) {
                // Show panel
                // this referred to global object, i.e. window
                p.style.display = "block";
            } else {
                // Hide
                p.style.display = "none";
            }
        }
    }
    
    showPanel(homePanel);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a little web layout. What I have so far is
I've been developing my first web based app for about two months now (I'm
I am trying to work with the layout of my web application. It's not
Hi Im new to GWT and Google App Engine. Im trying to layout which
I am trying to retrieve information from a web service call. The following is
Background: I'm trying to build a web app (as a personal project using modern
I am trying to connect my tablet to a Web Service that I have
I'm working on a web app that currently has a table-based layout. Ideally I'd
I am trying to implement jQuery UI tabs in my web app. I am
I am developing a web app in which I am trying to use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.