Uno spunto....
codice:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!--
function scanInput(e) {
ret = false;
//---------- IE o FF
if (!e) {
e = window.event;
carCorrente = String.fromCharCode(e.keyCode);
} else {
carCorrente = String.fromCharCode(e.which);
} // if (!e)
listaCaratteriAccettati = "0123456789";
if (listaCaratteriAccettati.indexOf(carCorrente) > -1) {
ret = true;
} // if (listaCaratteriAccettati.indexOf(carCorrente) > -1)
//----- Rifaccio il calcolo
prezzo = parseFloat(document.getElementById('p').value + carCorrente);
qta = parseFloat(document.getElementById('q').value);
totale = prezzo * qta;
if (isNaN(totale)) {
document.getElementById('t').value = "0";
} else {
document.getElementById('t').value = totale;
}
return ret;
} // function scanInput(e)
function assignScan() {
document.getElementById("p").onkeypress = scanInput;
} // function assignScan()
//-->
</script>
</head>
<body onload="assignScan()">
<table summary="">
<tr>
<td>Prezzo :</td>
<td>
<input type="text" name="p" id="p">
</td>
</tr>
<tr>
<td>Quantità :</td>
<td>
<input type="text" name="q" id="q" readonly="yes" value="3">
</td>
</tr>
<tr>
<td>Totale :</td>
<td>
<input type="text" name="t" id="t" readonly="yes" value="0">
</td>
</tr>
</table>
</body>
</html>