element.onkeypress = function() { // element should be your input field
var value = this.value; // get the value of the field
value *= cost; // multiply value by cost and save result; change cost to suit your needs
// set outputelement to the element where you show the result
outputelement.innerHTML = value; // set the text of the output field to the result;
}