TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Playing with JavaScript Adding & Dividing Numbers using JavaScript
Anurag Sarkar
May 12, 2020
5
k
0
2
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
Playing with JavaScript Adding & Dividing numbers using Java Script.
Playing with JavaScript Adding & Dividing numbers using JavaScript.
<!DOCTYPE html>
<html>
<body>
<p id=
"demo"
></p>
Enter Number One<input type=
"text"
name=
"no1"
id=
"1"
><br>
Enter Number Two<input type=
"text"
name=
"no2"
id=
"2"
><br>
<button onclick=
"myadd()"
>Press</button>
<p id=
"dem"
></p>
<script>
function
myadd() {
var
y = document.getElementById(
"1"
);
var
x = document.getElementById(
"2"
);
var
a = y.value;
var
b = x.value;
if
(a ==
""
) {
alert(
"Please Enter No 1"
);
return
}
if
(b ==
""
) {
alert(
"Please Enter No 2"
);
return
}
if
(a == b) {
alert(
"No cannot be Same"
);
return
}
else
{
var
c = parseInt(a) + parseInt(b);
document.getElementById(
"demo"
).innerHTML =
"On Adding"
+ c;
var
e = parseInt(b) / parseInt(a);
document.getElementById(
"dem"
).innerHTML =
"On Division"
+ e;
}
}
</script>
</body>
</html>
Playing with JavaScript Adding Dividing numbers using Java Script
Next Recommended Reading
Get And Set Variable Values From One JavaScript File To Another JavaScript File Using Local Storage