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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:54:51+00:00 2026-06-13T07:54:51+00:00

I have an index webpage that has a submit button on it. When I

  • 0

I have an index webpage that has a submit button on it. When I click that button, I want to run a function that adds a string to a div (using onclick()). However, it only flashes and then disappears. But when I use window.onload, it stays on the page, as I intend. Here’s the code:

<div>
  <form>
    <input type="submit" onclick="test();" value="Add Text">
  </form>
  <div id="holder"></div>
</div>

I include the following in my page with a “script” tag.

WHen I use this, it stays on the page (as it should):

window.onload = function(){
  $('#holder').html("Hello <b>world</b>!");
}

But this disappears right after it loads:

function test(){
  $('#holder').html("Hello <b>world</b>!");
}

Thanks!

  • 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-13T07:54:52+00:00Added an answer on June 13, 2026 at 7:54 am

    The button you are using is a form submit button, which will submit the form and reload the page.

    Instead use a <button> button

    Use

    <button onclick="test();">Add Text</button>
    

    instead of

      <form>
        <input type="submit" onclick="test();" value="Add Text">
      </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm viewing a webpage that's just a directory index. The index has folders and
I want to create a webpage that has a fixed part at the bottom
I have MVC 1.0 app on VS2008. I have webpage that has a search
I have a webpage that outputs a string that contains accented characters. I have
I have a Javascript function on my webpage that I'm displaying in a UIWebView:
I have the following directory structure : /script/x.js /includes/x.txt /1/2/index.html After hooking a webpage
i am using php 5.2.8 i have index.html, which loads LOAD.PHP from IFRAME. iframe
I have a index.php page that is the main page. All pages are included
Lets say we have a Company model, that has many Employees And has many
I want to make an html / css menu in my webpage that contain

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.