• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

How do I display the sum of two Text Inputs on the fly in Flex 3?


I can accomplish the following if a button was clicked or if I initiated it with a labelfunction (in a datagrid for example), but I can't figure out how to do this on the fly...

What I am trying to do is that when a user enters a Product Cost in one TextInput and the Taxes in another TextInput, I would like to have a label beneath that calculates the running total as the values are entered in...

Any insight would be greatly appreciated!!!!!!!  Thank you!!!!

<mx:Form width="100%" height="100%"   >
		          <mx:FormItem label="Total Product/Service Cost: $">
		                <mx:TextInput  id="Product_Cost" />
		          <mx:FormItem label="Taxes total: $" >
		                <mx:TextInput id="Taxes" />
		          <mx:FormItem label="Total: $" >

<!--this label obviously doesn't work, but the text is what I am trying to accomplish just in case my question wasn't clear enough.  Once again, THANK YOU!!!!!!!-->		                
<mx:Label id="Total"  text="{Product_Cost.text + Taxes.text}"/>

Open in new window

1 Solution

You can typecast the values to number and add.

<mx:Label id="Total"  text="{Number(Product_Cost.text) + Number(Taxes.text)}"/>

Open in new window

stracqanAuthor Commented:
Perfect!!! Thank you!!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now