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(addnumber s(1,2));
</script>
<Form>
<div id = "play_button" >
<input type = "button" value="click" onclick = "printnumbers(); return false;"></input>
</div>
</Form>
</html>
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(addnumber
</script>
<Form>
<div id = "play_button" >
<input type = "button" value="click" onclick = "printnumbers(); return false;"></input>
</div>
</Form>
</html>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
You are welcome.
ASKER
and wanted to display the value on clicking of a button.
When I did that button gets disappeared.
Your solution is correct. Thank you.