A simple JavaScript program that I wrote that will ask the user to give two numbers and then it will compute the difference of the two numbers and display the result in the screen.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.

Program Listing

   <title>Difference of Two Numbers in JavaScript</title>
 <style type="text/css">

 body {

 	font-family: arial;
 	font-weight: bold;
  display: inline-block;
  background-color: lightblue;
  padding: 6px;

  display: block;
  direction: rtl; 

  direction: ltr; 

  content: attr(data-text);

<script language="JavaScript">

function Solve(){

a = parseInt(document.difference.val_1.value);
b = parseInt(document.difference.val_2.value);

if (a > b) {
  result = a - b;
} else {
  result = b - a;
document.difference.diff.value = (result);

function Clear() {
document.difference.val_1.value ="";

<h3>Difference of Two Numbers in JavaScript</h3>
<form name="difference">
<label data-text="First Value">&nbsp;&nbsp;	
<input type="text" name="val_1" autofocus required>
<br />
<label data-text="Second Value">&nbsp;&nbsp;
<input type="text" name="val_2"required="">
<label data-text="Difference">&nbsp;&nbsp;<input type="text" name="diff" >
<br /> <br>
<input type="button" value="Convert" title="Click here to solve." onclick="Solve()" />
<input type="button" value="Clear"  
title="Click here to clear the text box."