Real-Time Calculation in Javascript: Based on text field and fixed price rate of an item

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;
}

Browse More Popular Posts

Leave a Comment