在一个警报中选定的项目

发布于 2024-11-03 10:55:49 字数 216 浏览 0 评论 0原文

大家好 我是 Flex 新手,所以如果这是新手问题,请原谅。
我有 2 个相关的组合框(国家和州)和一个提交按钮。
现在我想要的是用户提交表单后,它应该显示一个警报框,该警报框应该是 喜欢

selected country is "selected item"
selected state is"selected item"

谢谢

Hello everyone
I am new to flex so please excuse if it is noob question.
I have 2 comboboxes which are dependent (country and state) and one submit button.
Now what i want is after user submits the form it should display one alert box which should be
like

selected country is "selected item"
selected state is"selected item"

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

戏剧牡丹亭 2024-11-10 10:55:49

这是一个简单形式的示例

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" minWidth="955" minHeight="600">

    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;
            protected function button1_clickHandler(event:MouseEvent):void
            {
                Alert.show("Selected country is "+'"'+cm1.selectedItem+'"\n'+"Selected state is "+'"'+cm2.selectedItem+'"');
            }
        ]]>
    </mx:Script>

    <mx:ComboBox id="cm1" width="150" dataProvider="['a1','b1','c1']"/>
    <mx:ComboBox id="cm2" width="150" dataProvider="['a1a','b1b','c1c']"/>
    <mx:Button label="Submit" click="button1_clickHandler(event)"/>
</mx:Application>

Here is a sample in its simple form

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" minWidth="955" minHeight="600">

    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;
            protected function button1_clickHandler(event:MouseEvent):void
            {
                Alert.show("Selected country is "+'"'+cm1.selectedItem+'"\n'+"Selected state is "+'"'+cm2.selectedItem+'"');
            }
        ]]>
    </mx:Script>

    <mx:ComboBox id="cm1" width="150" dataProvider="['a1','b1','c1']"/>
    <mx:ComboBox id="cm2" width="150" dataProvider="['a1a','b1b','c1c']"/>
    <mx:Button label="Submit" click="button1_clickHandler(event)"/>
</mx:Application>
小矜持 2024-11-10 10:55:49
  • 要以文本形式获取每个组合框选定的项目,请使用 selectedItem.label请参阅此处
  • 要弹出警报,请使用 Alert.show请参阅此处
  • 对于字符串构建,请使用 + 运算符。

祝你好运。

  • For getting each combobox selected item as text use selectedItem.label. see here.
  • For popping alerts use Alert.show. see here.
  • For string building use + operator.

Good luck.

祁梦 2024-11-10 10:55:49
    <?xml version="1.0"?>
<!-- dpcontrols/ComboBoxEvent.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
   <mx:Script>
      <![CDATA[
         import mx.controls.Alert;
      ]]>
   </mx:Script>

   <mx:ComboBox id="mycb"> 
      <mx:ArrayCollection>
         <mx:Object label="AL" data="Montgomery"/>
         <mx:Object label="AK" data="Juneau"/>
         <mx:Object label="AR" data="Little Rock"/>
      </mx:ArrayCollection>
   </mx:ComboBox>
     <mx:ComboBox id="mycb2"> 
      <mx:ArrayCollection>
         <mx:Object label="US" data="United States"/>
         <mx:Object label="MX" data="Mexico"/>
         <mx:Object label="IR" data="Ireland"/>
      </mx:ArrayCollection>
   </mx:ComboBox>
   <mx:Button id="button1" label="Submit" click="Alert.show('Submit Successful!  State: '+{mycb.selectedItem}+' Country:'+{mycb2.selectedItem}, 'Alert Box', mx.controls.Alert.OK);"/>
" width="100"/>
</mx:Application>
    <?xml version="1.0"?>
<!-- dpcontrols/ComboBoxEvent.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
   <mx:Script>
      <![CDATA[
         import mx.controls.Alert;
      ]]>
   </mx:Script>

   <mx:ComboBox id="mycb"> 
      <mx:ArrayCollection>
         <mx:Object label="AL" data="Montgomery"/>
         <mx:Object label="AK" data="Juneau"/>
         <mx:Object label="AR" data="Little Rock"/>
      </mx:ArrayCollection>
   </mx:ComboBox>
     <mx:ComboBox id="mycb2"> 
      <mx:ArrayCollection>
         <mx:Object label="US" data="United States"/>
         <mx:Object label="MX" data="Mexico"/>
         <mx:Object label="IR" data="Ireland"/>
      </mx:ArrayCollection>
   </mx:ComboBox>
   <mx:Button id="button1" label="Submit" click="Alert.show('Submit Successful!  State: '+{mycb.selectedItem}+' Country:'+{mycb2.selectedItem}, 'Alert Box', mx.controls.Alert.OK);"/>
" width="100"/>
</mx:Application>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文