$("#SubA").ejCurrencyTextbox({
decimalPlaces: 2,
showSpinButton: false,
watermarkText: "$0.00",
//Bind the focusOut event for CurrencyTextBox
focusOut: "calculateTotal"
});
$("#SubB").ejCurrencyTextbox({
decimalPlaces: 2,
showSpinButton: false,
watermarkText: "$0.00",
//Bind the focusOut event for CurrencyTextBox
focusOut: "calculateTotal"
});
$("#Total").ejCurrencyTextbox({
decimalPlaces: 2,
showSpinButton: false,
watermarkText: "$0.00"
});
//LostFocus event for both SubA and sub B currency textbox
function calculateTotal() {
// Instance for SubA CurrencyTextBox, it’s used to access the value to that textbox
var subAObj = $("#SubA").ejCurrencyTextbox("instance");
// Instance for SubB CurrencyTextBox, it’s used to access the value to that textbox
var subBObj = $("#SubB").ejCurrencyTextbox("instance");
// Instance for Total CurrencyTextBox, it’s used to access the value to that textbox
var totalObj = $("#Total").ejCurrencyTextbox("instance");
//Using instance to get the values and add it
var total = subBObj.model.value + subAObj.model.value;
//Update the total values to Total currency textbox
totalObj.option("value", total);
} |