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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:16:06+00:00 2026-06-01T19:16:06+00:00

When a user puts in some text into my form and clicks the button,

  • 0

When a user puts in some text into my form and clicks the button, I want to hide the form and show a “thanks” message to the user to let them know I got their text.

By the way, this is for embedding into a Chrome extension pop-up.

Here’s what I have:

<!doctype html>
<html>
  <head>
    <title>Extension</title>
    <style>
      body {
        min-width:200px;
        min-height:75px;
        overflow-x:hidden;
      }

      img {
        margin:5px;
        border:2px solid black;
        vertical-align:middle;
        width:75px;
        height:75px;
      }

      .visible{
        display:block;
      }

      .invisible{
        display: none;
      }
    </style>

    <script>
      var PopupController = function () {
          this.button_ = document.getElementById('button');
          this.form_ = document.getElementById('userIdForm');
          this.userId_ = document.getElementsByName('userID')[0];
          this.submitThanks_ = document.getElementById('submitThanks');
          this.addListeners_();
      };

      PopupController.prototype = {
          button_: null,
          form_: null,
          userId_: null,
          submitThanks_: null,

          addListeners_: function () {
              this.button_.addEventListener('click', this.handleClick_.bind(this));
          },

          handleClick_: function () {
              console.log("Submit button clicked");
              var userId = this.userId_.value;

              // Hide the form
              this.form_.classList.add('invisible');
              this.submitThanks_.classList.remove('invisible');
          }
      };

    </script>
  </head>
  <body onload="window.controller = new PopupController()">
    <h2 class="invisible" id="submitThanks">Thanks!</h2>
    <div id="userIdForm">
      <form>
        <input type="text" name="userID" placeholder="User ID" required/>
        <button id="button" type="submit">Submit</button>
      </form>
    </div>
  </body>
</html>

The problem is that the form reappears after the button is clicked. I have noticed that the functionality slightly changes when I put in the required attribute into the input field.

I’m using the latest version of Chrome for Mac.

  • 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-01T19:16:08+00:00Added an answer on June 1, 2026 at 7:16 pm

    The form is reloading because the page is reloading, try returning false from your submit.

    <button id="button" type="submit" onclick="return false;">Submit</button>
    

    Edit

    Ah, sorry about that. So the page isn’t reloading?

    Perhaps try this instead:

          handleClick_: function () {
              console.log("Submit button clicked");
              var userId = this.userId_.value;
    
              // Hide the form
              this.form_.className = "invisible";
              this.submitThanks_.className = "visible";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically i'm trying to set something where a user enters some text into a
I'm having some trouble dealing with linebreaks here. Basically, the user puts in some
When a user puts in a CD and autoruns, I want to browse the
I have some code that downloads lessons as JSON, parses them, and puts them
What i want to do is that the user selects some fields on a
I have a process where a user puts in a comma delimited list that
I have a textbox where a user puts a string like this: hello world!
How to make the browser upload and display image after the user puts it
I am trying to use JavaScript to start a marquee when a user puts
My program puts an icon in the system tray because the user may minimize

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.