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 6834087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:04:05+00:00 2026-05-26T23:04:05+00:00

I have the Comments handle in my Google App Engine app to display the

  • 0

I have the Comments handle in my Google App Engine app to display the comments. I want to stop the page from loading if the user (defined as “chooser” here) is not in localStorage.

I get the first 2 alerts: "load event" and chooser: "undefined". Since “chooser” is undefined I expect the else clause to trigger but I don’t get the alert in else clause.

Also, the first item in ordered list is displayed but not the rest. So I assume there is an issue with loading of the page. How can I fix this?

class Comments(webapp.RequestHandler):
    def get(self):
        self.response.out.write("""
<html>
  <head>
    <title>Choices</title>
<script type="text/javascript">

function showChoices ()

{ 

  alert("load event"); 
  var chooser = localStorage.getItem("chooser"); 
  alert("chooser: " + chooser);

  if (chooser) 
  { 
    document.getElementById("topten").style.display="inline"; 
  }
  else 
  { 
    alert("else triggers"); 
    document.write("get an invitation"); 
  } 
}

  window.onload = showChoices;

      </script>

  </head>

  <body>
    <div class="content">""")

        #python code:
        query = Users.all()
        e = query.fetch(10)
        self.response.out.write("""<ol>""")
        for item in e:
            self.response.out.write("""
            <div id="topten" class="title" style="display:none">

                <li>%s (<span class="small">%s</span>)</li>

            </div>
            <hr><br />""" 
            % tuple([item.choice, item.owner]))
        self.response.out.write("""</ol>""")
        self.response.out.write("""
    </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-05-26T23:04:05+00:00Added an answer on May 26, 2026 at 11:04 pm

    Are you sure that chooser is undefined and not the string literal “undefined”?

    see this fiddle i made

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a user control to handle adding comments to certain business entities,
I have been struggling with a problem in Google App Engine and Django and
I have a site where each user's page shows comments and allows other user's
I have a page routed like /Comments/Search/3 where i search and display all the
I have built a website based on Google App Engine. It includes ten models,
I'd like to have comments in my code, but I want them to be
I'm working on a social networking system that will have comments coming from several
I am learning how to use Google App Engine / Python. (webapp) I am
Let's say I have Posts and Comments for a blog app using Rails and
im here with a nasty question. Drupal handle comments giving the user the choice

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.