some code was not required given in my previous post. following is the final one.
Add following javascript code before html body tag.
[code]
<script lang='javascript'>
function calculate()
{
//e is previous
//f is current
//g is new is f-e
previous=parseFloat(document.getElementById("e").value);
curr=parseFloat(document.getElementById("f").value);
if(!isNaN(previous) && !isNaN(curr) )
{
if(curr>=previous)
document.getElementById("g").value=curr-previous;
else … Read More

Dont be scared for that isNAN code, that is fine as utrivedi said. Sometimes the given input show an error as NAN (Not a number) means then given input is not a number. To identified and avoid that utrivedit used that. When u give strings then you can't get display in inputbox.

e feild is Previous reading
f feild is Present Reading
g is Caclulated by f-e
now I have another feild name a which is code of bill
and in DB I store code and there MF(Multiplying Factor)
Now I want my result g=(f-e)*MF
if Site id 8620 and mf 2 in DB Table
when user write 8620 in feild a it gets value of MF from DB and calculate g=(f-e)*MF

i) create a form with your input fields and a button.
<form name="frm" method="post" action="process.php">
ii) On submit it will the process the seperate php file, pass your a field value
$siteno=$_POST;
iii) Then connect your database and retrieve the specific value
iv) Then do the calculation.