Hi. I'm using the WebCurrencyEdit control to input several dollar amounts. I want to include a total field on the screen that should be updated on the client side as the user changes any of the other values. I've added an additional WebCurrencyEdit marked as read-only and initially load the total from the server. I'm having trouble writting the Javascript to update the total as values are changed.
I'm trying a line in my javascript function such as:
document.form1.TotalAmount.value = parseFloat(document.form1.AmountA.value) + parseFloat(document.form1.AmountB.value);
Any help would be appreciated.
You'll want to use functions from our client-side object model (CSOM) rather than looking at properties on our HTML elements.
I assume that TotalAmount, AmountA, and AmountB are the IDs of three WebCurrencyEdit objects on your page. Below is the corresponding JavaScript to waht you'd originally written:
// Get a reference to all three WebCurrencyEdit controlsvar wceTotalAmt = igedit_getById("<% =TotalAmount.ClientID %>");var wceAmtA = igedit_getById("<% =AmountA.ClientID %>");var wceAmtB = igedit_getById("<% =AmountB.ClientID %>");// Get the value of the two user-editable WebCurrencyEdit controls// I don't believe you need to use parseFloat here, but you'll want to verifyvar amtA = wceAmtA.getValue();var amtB = wceAmtB.getValue();// Set the total to the TotalAmount editorwceTotAmt.setValue(amtA + amtB);