当前位置: 代码迷 >> Web前端 >> 性别取舍标签RadioButton的使用
  详细解决方案

性别取舍标签RadioButton的使用

热度:206   发布时间:2012-11-03 10:57:42.0
性别选择标签RadioButton的使用

?一个RadioButton运用的例子,包含对标签的空值验证

?

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
           layout="absolute"
           verticalAlign="middle"
           backgroundColor="white" xmlns:ns1="*">
    
     <mx:Script>
           <![CDATA[
           private var sexChang:String;
           	import mx.controls.Alert;
               private function rb_change(evt:Event):void {
                 var rb:RadioButton = evt.currentTarget as RadioButton;
                  sexChang= rb.label;
               }   
               private function kk():void{
               textInput.text=sexChang;
               }                
        ]]>
     </mx:Script>
     <mx:Validator id="sexV" source="{sexRBG}" property="selectedValue" requiredFieldError="必须选择性别!"  trigger="{btnRegister}" triggerEvent="click"  listener="{maleRB}" />             
     <mx:FormItem label="性     别:" direction="horizontal" width="177" x="270" y="326">   	 
          <mx:RadioButtonGroup id="sexRBG"/>         
          <mx:RadioButton x="10" id="maleRB" groupName="sexRBG" label="男" value="1" change="rb_change(event)"/>               
          <mx:RadioButton id="femaleRB" groupName="sexRBG" label="女" value="0" change="rb_change(event)"/>          
     </mx:FormItem>  
    <mx:Button id="btnRegister" fontWeight="bold" click="kk()" x="294" y="373" width="88" height="45" label="选择性别" fontSize="13"/>
    <mx:TextInput x="270" y="266" id="textInput"/> 
</mx:Application>

?

  相关解决方案