Value of the ComboBox

I try to capture the value of the selected value of the ComboBox control data to send to a remote object, I just can't get the syntax right for this listing.


< mx:ComboBox dataProvider = "{sleep}" width = "150" close = "selectedItem = ComboBox (event.target) .selectedItem" id = "ptSleep" top = "250" left = "165" / > "

< mx:Script >
<! [CDATA]
[Bindable]
sleep public var: Array = [{Label: "», donnees", data: 0 "}, {label:"1 hour", given: 1}, {label:"2 hours", data: 2}, {label: '3 hours', data: 3}, {label:"4 hours", data: 4}, {label:"5 hours", data: 5}, {label:"6 hours", data: 6}, {label:"7 hours", data: 7}, {label: '8 hours', data: 8}, {label:"9 hours", data: 9}, {label: '10 hours', data: 10}, {label:"11 hours", data}] {: 11}, {label: "12 hours", data: 12}, {label: '13 hours', data: 13}, {label: "14 hours", data: 14}, {label: '15 hours', data: 15}, {label: '15 hours', data: 15}, {label: "16 hours", data: 16}, {label: "17 hours', data: 17}, {label:"18 hours", data: 18}, {label: '19 hours', data: 19}, {label:"20 hours", data: 20}, {label:"12 hours", data: 21}, {label: '22 hours', data: 22} [, {label: "23 hours', data: 23}, {label:"24 hours", data: 24}];

[Bindable]
public var selectedItem:Object;
[]] >
< / mx:Script >

It seems you don't need your selectedItem variable since it is stored in the ComboBox object. For example, you can reference the value selected with:

ptSleep.selectedItem.data

You can test this with this code:

private function show_selected (): void {}
trace (ptSleep.SelectedItem.Data);
}

If you want to access the value of the label and then it's just:
ptSleep.selectedItem.label

Vygo

Tags: Flex

Similar Questions

  • Creation of ComboBox with the values of the fields

    Hey everyone, it's been a while since my last post.

    I spent some time trying to fill a ComboBox with the values of the 3 fields of different form of google and I was wondering if someone could tell me on common sense.

    Thanks a lot for any idea!

    the general idea would be something like this:

    Get added to a table field values

    var aItems = [];

    aItems.push (getField("Text1").valueAsString);

    aItems.push (getField("Text2").valueAsString);

    aItems.push (getField("Text3").valueAsString);

    Fill the drop-down list with the elements box

    getField("combo1").setItems (aItems);

    Replace domain names with real field names that you use.

    You can start the list with an element that is a single space (if it appears empty) or something like "- select -". You can also make sure you add all the duplicate entries, which would happen if all the field values are the same.

    When did you want this script to run?

  • Get the value of select Combobox data

    Hi all

    I have a major issue while trying to get the value of the items selected through the change event in a combobox control.  Here is my code... I really need help ASAP... Thanks in advance

    public var test:ArrayCollection = new ArrayCollection([
                { Id:"one", Amount:2000 },
                { Id:"two", Amount:1000 },
                { Id:"three", Amount:200 } ]);

    protected function regionCB_changeHandler(event:ListEvent):void
                   {
                      Alert.show(//tried so many things here to acces the items amount field.. nothing is working
                   }
    <s:ComboBox change="regionCB_changeHandler(event)" dataProvider="{test}" labelField="Id" id="regionCB" visible="false" />

    Have you tried selectedItem.Amount?

  • How can I get the value of a comboBox element in a grid?

    Hi all

    I have a DataGrid with some comboBoxes in two of its columns.

    What I need to do, is get these boxes of bombo values when a user highlights the line of the grid NOT when user use the comboBox control. I understand how to extract the values once the change handler is called on the drop-down list, but I don't see a way to get to the comboBoxes that belong to the gridRow highlighted.

    I'm sure it's really simple, but I'm not able to find a reference on how it's done. Any help much appreciated.

    Copy the following code shows how you can do it if you know the dataProvider for ComboBox data fields.

    If this post has answered your question or helped, please mark it as such.


    http://www.Adobe.com/2006/mxml '.
    Initialize = "initData ()" > "
      
       Import mx.events.ListEvent;
    Import mx.collections. *;
    private var DGArray:Array =]
    {Artist: 'Pavement', Album: 'Slanted and Enchanted' price: 11.99, combo1: [1,2,3], combo2: [100,200,300]},
    [{Artist: 'Pavement', Album: 'Brighten the corners', price: 11.99, combo1: [2,4,6] combo2: [200,400,600]}] ;
            
    [Bindable] public var initDG:ArrayCollection;
    public function initData (): void {}
    initDG = new ArrayCollection (DGArray);
    }
         
    private void dgChangeHandler(event:ListEvent):void {}
    var ac:ArrayCollection = event.currentTarget.dataProvider;
    txt. Text = "";
    txt. Text += ac.getItemAt (event.rowIndex) .combo1 + "\n";
    txt. Text += ac.getItemAt (event.rowIndex) .combo2;
    }
    ]]>
      


    dataProvider = "{initDG}" change = "dgChangeHandler (event); » >
         
            
            
            
            
             
              
               
                
               

              

             

            

            
             
              
               
                
               

              

             

            

         

      
      

  • How to change the ADF Faces component visibility in changing the comboBox value?

    Hi all
    I want to change visibility panelGoupLayout true false when I choose a comboBox value, I can do this by using a commandButton control, but my question is how to change using the comboBox to the bean to support value, can anyone help me? Besides my English is not enough, I hope that I could say to my problem.
    Thank you.
    Ali

    Published by: user12246056 on November 23, 2009 09:01

    Hello

    You must add the id of the selectOneChoice as partialTriggers to the panelGroupLayout - check my example above.

    partialTriggers="soc1"
    

    Also, you seem to keep the selectOneChoice inside the panelGroupLayout (who you want to fake visible). So, once you make the invisible panelGroupLayout, the selectOneChoice (which is inside your panelGroupLayout) will become also invisible. Cordially (put out the panelgrouplayout if she not how you wanted it to be).

    Arun-

  • The ComboBox value width problem

    Hey all,.

    Someone knows that, when I give my comboBox width by default, and I use it for the first time, the menu drop down is still the same size.
    When the comboBox control is pressed again, the combo comes with the given size.

    Please check the link for demo image:

    [http://s13.postimg.org/6954yibvr/Error.jpg]

    Kind regards
    Aerts

    The ComboBox tutorial with setPrefWidth() example works as expected.
    http://docs.Oracle.com/JavaFX/2/ui_controls/combo-box.htm#BABJCCIB
    Please send your code that shows your question.

  • How can I set up an instance of the comboBox control to a certain value (without to know the index number)?

    I have a ComboBox with it pre-populated with the States.

    When I have a variable which says she must be selected to for example, how to do this, without having to understand the index number for each State?

    Thank you

    You could loop through the combobox items to find and set the selection...

    var preselectedState = "CA";

    for (i = 0; i
    If (cb.getItemAt (i) .label == preselectedState) {}
    cb.selectedIndex = i;
    break;
    }
    }

  • Assignment of values to a combobox

    Hello everyone

    I'm quite new to labview... could someone please help me with the use of the combobox. My task is "when I select an item in the combobox must read the data from a spreadsheet and it disply on the front panel." "The worksheet data, I needed to add some values manually and save it as a new file. Could some contact please me in detail how could I do. Thanks in advance

    Best regards

    Julien

    Hi Alain,

    Take a look at the attached vi. It can help you move forward. I would strongly advice to study the basics of the structures of the event and their uses. It will be handy if you plan to do good projects of LV.

    Kind regards
    Amine31

    (Give glory to good answers, mark it as a Solution If your problem has been solved )

  • Load the items of the combobox file

    Hello

    I don't know how to use correct components here, but I tried to load some drop-down list items file selector. I have the file, what has changed all the time, so I have to load those to selectro menu drop-down user every time that when the program starts. Eny ideas?

    A.A

    Use of a Strings property node

    The property strings]

    [ Short name: chains]

    Request: Basic package

    Class: ComboBox properties

    Array of strings which you can select in the control drop-down list box. String values and [of] property allows you to specify values for each string.

    If you use this property with a list box control that has custom values, the number of values for the drop-down list box control determines the number of strings that you can set using this property. For example, if the combo box control has the values given, free and complete, you can set only three strings using this property.

    If the combo box control has more values the number of channels that connect to this property, LabVIEW creates channels for all values that have no corresponding channels. For example, if the combo box control has the only free values, Discount and full and wire you channels coupon and Coupon to this property, LabVIEW sets the last string of .

    This property is similar to the element to change the items in the context menu of a control area combo and the option of labels on the page change the items in the drop-down list box-properties dialog box.

  • Compare the text of the combobox as a condition in the calculation of the field another.

    I'm doing a condition, if one of the 15 comboboxes has a certain value of selected text list, then a button is displayed.

    I tried to follow this example, which I found here on another question:

    var t = document.getElementById ("fTerminalType");

    selectedText var = t.options [t.selectedIndex] .text;

    the part of my code that uses it is:

    for (i = 1; i < 16; i ++) {}

    var t = this.getField ("ComboBox" + i);

    var s = t.options [t.selectedIndex] .text;

    If (s == 'Specific text') {}

    k.Display = display.visible;

    }

    }

    "Combobox1" so has "A specific text" selected, but the "k" key does not appear visible, and the rest of the code (a calculation) returns empty.

    If I delete the internal code of "for () {}", the rest of the calculation works, if the syntax error is specific to the part of text comparison.

    I tried 'value', ".innerHTML", ". export.value", '.change' and '.changeEx' instead of '.text', nothing has worked.

    I don't know if pdf forms have jQuery, I could try it but that he would need assistance with the code so be it.

    Thank you.

    The value property returns the value of export of the selected item if it has one, otherwise it returns what appears, which is what you call text. SO if someone type something, you can retrieve it with the value property, even though you really better to use valueAsString. Check the console JavaScript (Ctrl + J) to see if errors are reported.

    If you need to get the value of the export value display, you can use the field currentValueIndices property to get the index of the selected item and use it with the field getItemAt method to get the display value. A code example is the Acrobat JavaScript reference.

    I don't notice anything wrong with your script updated, if you add a break after the k.display statement statement, since you do not need to keep a loop once it is set. Unclear if it is initialized to display.hidden somehow, what would make sense.

  • How is the ComboBox extends beyond the borders of the window?

    I noticed that the ComboBox control may extend beyond the borders of the window. I would like to implement something like that to a custom control of the mine, but can't find a way to do it. I know that happens simply to allocate a large enough value via setVisibleRowCount, but what interests me is how the combobox can be larger than the pane that is in that I can copy this behavior for my own control.

    Here is a screenshot to clarify what I mean.

    Thanks in advance

    The part of the ComboBox popup is represented by a PopupControl. It's a subclass of window, it is not constrained by the limits of the window in which is placed the ComboBox control.

  • Rendering selected in the combobox element

    That may suggest the title!
    I am facing a problem rendering the selected item in the combobox ^^
    import javafx.application.Application;
    import static javafx.application.Application.launch;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.ComboBox;
    import javafx.scene.control.ContentDisplay;
    import javafx.scene.control.ListCell;
    import javafx.scene.control.ListView;
    import javafx.scene.image.Image;
    import javafx.scene.image.ImageView;
    import javafx.scene.paint.Color;
    import javafx.stage.Stage;
    import javafx.util.Callback;
    
    /**
     *
     * @author Minedun6
     */
    public class CustomComboBox extends Application {
    
        @Override
        public void start(Stage primaryStage) {
            Group root = new Group();
            ComboBox box = new ComboBox();
            box.setPrefSize(150, 60);
            //ObservableList<String> data = FXCollections.observableArrayList("Google Chrome", "FireFox", "Safari", "Opera");
            //box.getItems().add(data);
            box.getItems().addAll(new Image("http://cdn1.iconfinder.com/data/icons/fs-icons-ubuntu-by-franksouza-/32/google-chrome.png"),
                    new Image("http://cdn1.iconfinder.com/data/icons/humano2/32x32/apps/firefox-icon.png"),
                    new Image("http://cdn1.iconfinder.com/data/icons/fatcow/32x32/safari_browser.png"),
                    new Image("http://cdn1.iconfinder.com/data/icons/fatcow/32/opera.png"));
            box.setCellFactory(new Callback<ListView<Image>,ListCell<Image>>(){
                @Override
                public ListCell<Image> call(ListView<Image> p) {
                    //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
                return new ListCell<Image>(){
                 private final ImageView view;
                 { 
                            setContentDisplay(ContentDisplay.GRAPHIC_ONLY); 
                            view = new ImageView();
                        }
                 @Override
                 protected void updateItem(Image item, boolean empty) {
                            super.updateItem(item, empty);
                            
                            if (item == null || empty) {
                                setGraphic(null);
                            } else {
                                view.setImage(item);
                                setGraphic(view);
                            }
                       }
                };
                
                }   
            });
            
            
            box.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Image>(){
    
                @Override
                public void changed(ObservableValue<? extends Image> ov, Image t, Image t1) {
                    
                }
            });
            
            
            Scene scene = new Scene(root, 300, 250);
            root.getChildren().addAll(box);
            primaryStage.setTitle("Hello World!");
            primaryStage.setScene(scene);
            primaryStage.show();
        }
    
        /**
         * The main() method is ignored in correctly deployed JavaFX application.
         * main() serves only as fallback in case the application can not be
         * launched through deployment artifacts, e.g., in IDEs with limited FX
         * support. NetBeans ignores main().
         *
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            launch(args);
        }
    }
    so when the context menu is displayed, the images display correctly, but when I select the image, it does not, it shows me the following "javafx.scene.image.Image".
    Another thing is for each image I want to display a text!
    If I can get it work, I'll post a thread indicating how to fill combobox with images, text of the database ^^
    Hopefully I can find useful assistance once again ^^
    In addition, thx D of James ^^

    Define a class to wrap the name of the browser and its icon:

    Browser.Java

    import javafx.scene.image.Image ;
    public class Browser {
      private final String name ;
      private final Image icon ;
      public Browser(String name, Image icon) {
        this.name = name ;
        this.icon = icon ;
      }
      public Image getIcon() {
        return icon ;
      }
      public String getName() {
        return name ;
      }
      @Override
      public String toString() {
        return name ;
      }
    }
    

    Now you can do:

    import javafx.application.Application;
    import static javafx.application.Application.launch;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.ComboBox;
    import javafx.scene.control.ContentDisplay;
    import javafx.scene.control.ListCell;
    import javafx.scene.control.ListView;
    import javafx.scene.image.Image;
    import javafx.scene.image.ImageView;
    import javafx.scene.paint.Color;
    import javafx.stage.Stage;
    import javafx.util.Callback;
    
    /**
     *
     * @author Minedun6
     */
    public class CustomComboBox extends Application {
    
        @Override
        public void start(Stage primaryStage) {
            Group root = new Group();
            ComboBox box = new ComboBox();
            box.setPrefSize(150, 60);
            //ObservableList data = FXCollections.observableArrayList("Google Chrome", "FireFox", "Safari", "Opera");
            //box.getItems().add(data);
            box.getItems().addAll(new Browser( "Chrome", new Image("http://cdn1.iconfinder.com/data/icons/fs-icons-ubuntu-by-franksouza-/32/google-chrome.png")),
                    new Browser("Firefox", new Image("http://cdn1.iconfinder.com/data/icons/humano2/32x32/apps/firefox-icon.png")),
                    new Browser("Safari", new Image("http://cdn1.iconfinder.com/data/icons/fatcow/32x32/safari_browser.png")),
                    new Browser("Opera", new Image("http://cdn1.iconfinder.com/data/icons/fatcow/32/opera.png")));
            box.setCellFactory(new Callback,ListCell>(){
                @Override
                public ListCell call(ListView p) {
                    //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
                return new ListCell(){
                 private final ImageView view;
                 {
                           //  setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
                            view = new ImageView();
                        }
                 @Override
                 protected void updateItem(Browser item, boolean empty) {
                            super.updateItem(item, empty);
    
                            if (item == null || empty) {
                                setGraphic(null);
                                setText(null);
                            } else {
                                view.setImage(item.getIcon());
                                setGraphic(view);
                                setText(item.getName());
                            }
                       }
                };
    
                }
            });
    
            box.getSelectionModel().selectedItemProperty().addListener(new ChangeListener(){
    
                @Override
                public void changed(ObservableValue ov, Browser t, Browser t1) {
                    String browserName = t1.getName();
                    Image browserIcon = t1.getIcon();
                    // do whatever you need with the browserName and icon...
                }
            });
    
            Scene scene = new Scene(root, 300, 250);
            root.getChildren().addAll(box);
            primaryStage.setTitle("Hello World!");
            primaryStage.setScene(scene);
            primaryStage.show();
        }
    
        /**
         * The main() method is ignored in correctly deployed JavaFX application.
         * main() serves only as fallback in case the application can not be
         * launched through deployment artifacts, e.g., in IDEs with limited FX
         * support. NetBeans ignores main().
         *
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            launch(args);
        }
    }
    

    You can of course add more fields to your class of browser if you need. You can also consider getting browser an enum [url http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html].

  • Use the button to select the Combobox choices?

    Hi all

    I have a combobox (called "style_cb") and that you have guseed you can use to select a "style."

    The site also contains photos and I would like users to be able to click on the photos (which are the buttons) and have the combobox control

    automatically the value of this option.

    So, if the options in the drop-down list are "oranges, apples, pears, cherries" and the images are the same fruit.

    then by clicking on a picture of a fruit (say "cherriesBtn") would set the drop-down list for this option box.

    I played a little and I read the help - searched the net but no joy so far.

    All gurus like to help them with what I imagine, it's a fairly simple thing?

    Best wishes

    Tony

    You can use the selectedIndex property of your combobox:

    {cherriesBtn.onRelease = function ()}

    style_cb. SelectedIndex = 3;

    }

  • How to use the Combobox selection to check one of the six boxes?

    I have a combobox with 6 choices ["' (0), RED (1), ORANGE (2), YELLOW (3), GREEN (4), BLUE (5)" "] and I want to place controls in one of the six boxes.

    The comboboxes are all named fnfCB-box, and each of the six have an export value of 0-5, match the choices I can make from the drop-down list.

    If a choice is made in the drop-down list box, the correct checkbox must be checked. If no choice is made in the combobox, no boxes must be selected.

    What are my next steps? Most of the tips seem to work the other way (click on checkbox, update list dropdown value)...

    You can use a custom script to strike for the drop-down list box:

    // Custom Keystroke script for combo box
    if (!event.willCommit) {
        getField("fnfCB-box").value = event.changeEx;
    }
    

    Select the 'value selected to validate immediately' option to the drop-down list box.

  • How to use the combobox control to filter datagrid in Flash Builder 4?

    Hello

    I worked through the TestDrive with Flash Builder 4 application and I would like to know how to filter a datagrid using a combobox control.  I googled the subject and results for many different versions of Flash, some who look like they're going to take a considerable amount of time to implement.  I hope, with Flash Builder 4, there is a simple way to do this without writing code pages.

    I think I can be close to getting this work by passing the combobox value in a PHP script that queries the database with a WHERE clause.

    Thakns,

    David

    On the change of the ComboBox, you can filter on the ArrayCollection.source that contains the data. And define the table filtered as the dataprovider for a datagrid. Take a look at the function of class filter Array.

    -Gerard

    http://www.gauravj.com/blog

Maybe you are looking for

  • How to uninstall a plug-in?

    Running Win 8.1. FF 42.0 indicates Citrix Plugin, but no Citrix in Add/Remove programs in Control Panel. How can I get rid of the Citrix plugin?

  • Mouse and keyboard devices and wireless losing charge quickly battery USB draining energy

    I have an iMac with keyboard and wireless mouse (OS X 10.6.8).) Recently, I'll have to replace the AA batteries on an almost daily basis. Anyone have any ideas? I use rechargeable batteries and they are new, so not down for used batteries. If I try t

  • Installing the printer USB Orbi

    Got the routner all hooked and blazing away wireless and wired. However, I am not able to get the usb printer, I plugged in to operate. I have a R7000 with the readyshare, so I know the printer works. Why on this device can't connect my printer to th

  • Problem upgrade memory on the Satellite L30 - 11 d

    Hi all I'm trying to update the memory from 512 MB to 2 GB. I have used Crucial memory Tester and ordered memory: 2 X 1 GB DDR2 667 CL5I can use either chip in a memory slot, but not the two chips at the same time I've updated the BIOS Any ideas? Che

  • Compatible hard disk for Pavilion a566n?

    I know it's a basic question, but I am trying to determine what are my options to replace a hard drive in my a566n.    The vehicle has currently two readers... master is a 40 G Western Digital (WDC WD400BB-00DEA0) and the slave is a 20 G Maxtor.    I