3 Replies Latest reply on Aug 7, 2007 5:06 PM by PJKTech

    Getting combobox value in Flex


      As you can see below, I just want to display the selected combobox value via an Alert initially. Why can't I get the selectedItem value? I've tried everything, but I can't get it right. (My first Flex experimentation.)

      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="news.send()" viewSourceURL="/flex/newsSelection.mxml">

      <mx:HTTPService
      id="news"
      url=" http://localhost/rss/rss_all.php"
      useProxy="false"
      method="POST">
      </mx:HTTPService>

      <mx:Script>
      import mx.controls.Alert;

      //public var newsTitles:Array = news.lastResult.rss.channel.item.title;

      public function goToURL(urlStr:String):void {

      var webPageURL:URLRequest = new URLRequest( urlStr );
      navigateToURL(webPageURL, &apos;_blank&apos;)

      }//end function goToURL

      public function showAlert(urlStr:String):void {
      Alert.show(urlStr);
      }

      </mx:Script>

      <mx:Form x="12" y="8" width="344">
      <mx:ComboBox id="newsCombo" width="200" dataProvider="{news.lastResult.rss.channel.item}" labelField="title" /> <mx:Button x="293" y="5" label="Go!" click="showAlert(String (newsCombo.selectedItem) )" id="btnSend" width="30" height="20"/>
      </mx:Form>

      </mx:Application>