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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:11:26+00:00 2026-06-18T03:11:26+00:00

So I have a webpage that has a form. The form is linked to

  • 0

So I have a webpage that has a form. The form is linked to a switch statement, and depending on what the user inputs, it returns some value. However, after the value is returned, I want to provide an option to go back to the original form without refreshing the page. Since the javascript is all client side, the data is rendered in the div that I have specified, and I basically just want to refresh that area back to the original form via adding a button. In my switch statement, I have tried appendeding, style.display, and even writing a toggle function and it’s not working.

Here is my HTML and JS:

function verifyPres(form) {
var president = form.day.value.toUpperCase();

switch (president) {
    case "GEORGE WASHINGTON":
        document.getElementById("form").remove();
        document.getElementById("id1").textContent=george[0];
        document.getElementById("id2").textContent=george[1];
        document.getElementById("id3").textContent=george[2];
        document.getElementById("id4").textContent=george[3];
        document.getElementById("id5").textContent=george[4];
        document.getElementById("id6").textContent=george[5];
        document.getElementById("id7").textContent=george[6];
        document.getElementById("id8").textContent=george[7];
        break;
    case "JOHN ADAMS":
        document.getElementById("form").remove();
        document.getElementById("id1").textContent=adams[0];
        document.getElementById("id2").textContent=adams[1];
        break;
    default:
        document.getElementById("form").remove();
        document.getElementById("id1").textContent='Sorry, that is not a president!';
}

}

<div class="recipe">
                <form id="form" name="myForm">
                    <b>Please enter your favorite US President:</b><br>
                      <div id="input"><input type=TEXT value="" name="day" style="font-family: 'abraham_lincolnregular'; font-size: 1.2em; color: #544841;"></div>
                      <div id="return"></div>
                      <div id="ticket"><input class="button" type=BUTTON value="" name="myButton" onClick='verifyPres(this.form)'></div>
                </form>
                <h3 id="id1"></h3>
                <div id="list">
                    <div id="id2"><p></p></div>
                    <div id="id3"><p></p></div>
                    <div id="id4"><p></p></div>
                </div><!--list-->
                <div id="id5"><p></p></div>
                <div id="id6"><p></p></div>
                <div id="id7"><p></p></div>
                <div id="id8"><p></p></div>
            </div><!--recipe-->
  • 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-18T03:11:27+00:00Added an answer on June 18, 2026 at 3:11 am

    Have you tried .reset()?

    document.getElementById("form").reset();
    

    I would highly suggest that, if these elements are going to be accessed and manipulated often, you cache them into variables, something along these lines:

    var id1, id2, id3, id4, id5, id6, id7, id8;
    id1 = document.getElementById("id1");
    id2 = document.getElementById("id2");
    // etc...
    

    That way, they are ready for you to manipulate as often as you like, without having to force the DOM to find them each time.

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

Sidebar

Related Questions

I have a webpage that has 3 file inputs. There are specific fields on
I have a webpage that requires login. Once a user has logged in I
I will create a webpage that has a sidebar, and the sidebar will have
I have a webpage built with a dropdown that has a list of books.
I have a Google Map on the webpage with markers on it that has
I have a webpage that when landed on, will detect a user's physical location
I am working on a webpage where I have a main landing-page that has
I have an index webpage that has a submit button on it. When I
I have a form that a user fills out, which submits information to my
I currently have a Rails website that has some Prototype scripting in it. My

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.