A simple program that I wrote using JavaScript and HTML forms to accept a number from the user and then the program will check and determine if the given number is positive or number.
If you have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360.
Program Listing
<html>
<style>
body,p {
font-family:arial;
font-size:16px;
}
</style>
<body>
<h3> Positive and Negative Number Checker </h3>
<br/>Enter a Number
<input type="text" id="num_value" name="num_value" size="5">
<br><br>
<button onclick="check_number()">Check Number</button>
<br><br>
<p id="demo"></p>
<script>
function check_number() {
var num_value= document.getElementById("num_value").value;
if (num_value >=0 ) {
result = num_value + " is a Positive Number.";
}
else {
result = num_value +" is a Negative Number.";
}
document.getElementById("demo").innerHTML = result;
}
</script>
</body>
</html>
No comments:
Post a Comment