View Full Version : Checkbox and Adding issue in Flex2.
Ghost3313
05-22-2008, 11:31 PM
I am currently working on an application where I need to add amounts based on a user clicking checkboxes to create a total.
And after 3 weeks, no madder what I do I cant get it to work correctly.
Does anyone have an idea how how to make this work?
Ghost3313
kahuja
05-23-2008, 01:50 PM
You example is vague - can you provide specifics maybe I can help.
Ghost3313
05-24-2008, 09:56 AM
Sorry about that , The whole idea is that when the 10.00 checkbox "Check01" is selected that it will add it, and display $10.00, when selcecting both it will add the $5.00 to the total.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Panel x="310" y="165" width="225" height="165" layout="absolute">
<mx:CheckBox x="15" y="21" label="$10.00" id="Check01"/>
<mx:CheckBox x="131" y="21" label="5.00" id="Check02"/>
<mx:TextInput x="131" y="47" editable="false" text="0.00" width="42" id="Amount"/>
<mx:TextInput x="131" y="77" editable="false" text="0.00" width="42" id="AmountWTAX"/>
<mx:Label x="15" y="49" text="Total Amount"/>
<mx:Label x="15" y="79" text="Total w/Tax 8.25%"/>
</mx:Panel>
</mx:Application>
kahuja
05-24-2008, 10:09 AM
You can write logic in many ways, below is just one of them.
ActionScript Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:Script>
<![CDATA[ private function calcAmount():void { var amt:int = 0;
if(Check01.selected) { amt = amt + 10;
} if(Check02.selected) { amt = amt + 5;
} Amount.text = amt.toString();
}
]]>
</mx:Script>
<mx:Panel x="310" y="165" width="225" height="165" layout="absolute">
<mx:CheckBox x="15" y="21" label="$10.00" id="Check01" click="calcAmount();"/>
<mx:CheckBox x="131" y="21" label="5.00" id="Check02" click="calcAmount();"/>
<mx:TextInput x="131" y="47" editable="false" text="0.00" width="42" id="Amount"/>
<mx:TextInput x="131" y="77" editable="false" text="0.00" width="42" id="AmountWTAX"/>
<mx:Label x="15" y="49" text="Total Amount"/>
<mx:Label x="15" y="79" text="Total w/Tax 8.25%"/>
</mx:Panel>
</mx:Application>
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.