Link to home
Create AccountLog in
Avatar of sakthikumar
sakthikumar

asked on

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>
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of sakthikumar
sakthikumar

ASKER

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.
You are welcome.