Java script, button disappears after clicked.

Hi

I am new to java script to HTML. Below is my code.
which displays a button. Problem is the button disappears after the execution onclick function.

Can you help me to fix this.

<html>
<head>
<title> My first java script program </title>
<style type="text/css">
    #play_button {
    position:absolute;
   
    top: 50px;
    left: 200px;
   
}
 </style>
</head>
<script type = "text/javascript">
function addnumbers(x,y){
var x = x+y;
return x;
}
function printnumbers(){
var x = addnumbers(12,23);
document.write(x);
}
//document.write(addnumbers(1,2));
</script>
<Form>
<div id = "play_button" >
<input  type = "button" value="click" onclick = "printnumbers(); return false;"></input>
</div>
</Form>
</html>
sakthikumarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
What are you wanting to do
document.write(x);

Open in new window

this is not something you want to be doing after loading the document.
Here is some code that writes the result to a div on the page
Let us know what your objective is so we have a context.
 
<!doctype html>
<html>
<head>
<title> My first java script program </title>
<style type="text/css">
#play_button {
  position:absolute;
  top: 50px;
  left: 200px;
}
</style>
</head>
<script type = "text/javascript">
function addnumbers(x,y)
{
  var x = x+y;
  return x;
}
function printnumbers()
{
  var x = addnumbers(12,23);
  document.getElementById('output').innerHTML = x;
}
//document.write(addnumbers(1,2));
</script>
<Form>
  <div id = "play_button" >
    <input  type = "button" value="click" onclick = "printnumbers(); return false;"></input>
  </div>
  <div id="output"></div>
</Form>
</html>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sakthikumarAuthor Commented:
I tried to call a function from a function that calculates a value.

and wanted to display the value on clicking of a button.

When I did that button gets disappeared.

Your solution is correct. Thank you.
Julian HansenCommented:
You are welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.