Ciao... non sono stato proprio ad analizzare il tuo codice, ma questo è un esempio che funziona
Codice PHP:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta name="GENERATOR" content="Quanta Plus" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function somma() {
var a=parseFloat(document.getElementById("a").value.replace(",","."));
var b=parseFloat(document.getElementById("b").value.replace(",","."));
c=a-b;
document.getElementById("differenza").value=c;
return false;
}
</script>
</head>
<body>
<input type="text" name="a" id="a" onKeyUp="somma()" >
<input type="text" name="b" id="b" onKeyUp="somma()" >
<input type="text" name="differenza" id="differenza">
</body>
</html>