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

Posted on 2009-12-22
Medium Priority
Last Modified: 2013-11-11

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

Question by:stracqan
LVL 11

Accepted Solution

vindys80 earned 1600 total points
ID: 26109751

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


Author Closing Comment

ID: 31669260
Perfect!!! Thank you!!!

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question