Kmspico Download | Official KMS Activator Website [New Version 2024] Fast and Easy Converter YouTube to MP3 Online KMSAuto Net Activator Download 2024 Immediate Byte Pro Neoprofit AI Blacksprut without borders. Discover new shopping opportunities here where each link is an entrance to a world ruled by anonymity and freedom.

How to Create Even and Odd Numbers Calculator in JavaScript?

Experts php tutorial has come up with a new topic. That how you will make calculator to get odd and even number through Jquery or JavaScript program. So let’s go guys, you must have printed odd and even number on your local server through javascript program. You will be told today how the calculator to print odd number is made by javascript program.

Create HTML code.

To get odd and even number through calcutor, you have to first create the form in an html. So first of all you create the form in html. In the form, you have to take an input type of text. And then a submit button. You are given the code of the form with the example below. With the help of which you can understand.

<!DOCTYPE html>
<html>
<head>
<title>JavaScript to find Odd or Even number Example - Experts PHP</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h2>JavaScript to find Odd or Even number!</h2>
<form method="post">
Enter a number: <input type="number" id="num" name="num" min="0" />
<input type="button" value="Find Odd or Even" onclick="findOddEven()" name="find" />
<div style="margin-top: 10px;" id="result"></div>
</form>
</body>
</html>

Creat javascript code of odd and even number print.

Now you have been told about the most important code below. You can get odd and even number with the help of this code. Now you can understand this code by looking below.

<script>
function findOddEven(){
var num = document.getElementById('num').value;
if ( num % 2 == 0) {
document.getElementById('result').innerHTML = num + ' is an Even number';
}else{
document.getElementById('result').innerHTML = num + ' is an Odd number';
}
} 
</script>

Mix html/JavaScript Code in One File (odd-even-numbers-calculator.html).

Now you have to add this code to a single file (odd-even-numbers-calculator.html). The example of which is given below. You can copy the code of this file to your javascript. You can use it by adding it to the file.

odd-even-numbers-calculator.html

<!DOCTYPE html>
<html>
<head>
<title>JavaScript to find Odd or Even number Example - Experts PHP</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
function findOddEven(){
var num = document.getElementById('num').value;
if ( num % 2 == 0) {
document.getElementById('result').innerHTML = num + ' is an Even number';
}else{
document.getElementById('result').innerHTML = num + ' is an Odd number';
}
} 
</script>
</head>
<body>
<h2>JavaScript to find Odd or Even number!</h2>
<form method="post">
Enter a number: <input type="number" id="num" name="num" min="0" />
<input type="button" value="Find Odd or Even" onclick="findOddEven()" name="find" />
<div style="margin-top: 10px;" id="result"></div>
</form>
</body>
</html>