Hello Guys, i have a small problem. i have this form where i calculated updated balance based on data already available and data from 2 text inputs. the result is correct but i would like that when someone types in one textinput the balance is computed and then further if someone inputs a figure in the second text input. below is the code i got as of now. It needs improvement.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
horizontalAlign="center"
verticalAlign="top">
<mx:Script>
<![CDATA[
private function calBalance(event:Event):void
{
var amt:Number=new Number;
if (Number(amountPaid.text) > Number(currentPaid.text) && Number(manFees.text) > Number(currentFees.text)){
amt = Number(currentBal.text) - ((Number(amountPaid.text) - Number(currentPaid.text)) + (Number(manFees.text) - Number(currentFees.text)))
}
balance.text=amt.toFixed(0);
}
]]>
</mx:Script>
<mx:Panel height="400"
layout="vertical">
<mx:HBox>
<mx:Label text="Payment:"
width="113"/>
<mx:TextInput id="amountPaid" change="calBalance(event)"/>
<mx:Label text="Management Fees:"/>
<mx:TextInput id="manFees" change="calBalance(event)"/>
</mx:HBox>
<mx:HRule width="100%"/>
<mx:HBox>
<mx:Label text="Current Balance:"
width="126"/>
<mx:Text text="515000"
id="currentBal"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="Amount Already Paid:"
width="126"/>
<mx:Text text="500000"
id="currentPaid"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="Fees Paid:"
width="126"/>
<mx:Text text="0"
id="currentFees"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="updated Balance:"
width="126"/>
<mx:Text id="balance"/>
</mx:HBox>
</mx:Panel>
</mx:Application>
| Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (1) |
Actually this is the entire code with 2 scenarios. but needs a liltle tweaking to make it better. by better i mean, the balance starts off getting computed the moment either the amountPaid textinput or manFees textinput is being fed in a figure. thanks
Any help guys?
Hello, thanks for the response. i am already using a change listener on the text input but when i start typing in the first textinput, i don't get the desired result. its only when i type in both that the evnet kicks in.
Hello, thanks for the response. i am already using a change listener on the text input but when i start typing in the first textinput, i don't get the desired result. its only when i type in both that the evnet kicks in.