1 Reply Latest reply on Mar 4, 2008 3:31 AM by rlc5611

    "if" related to ComboBox

    GerryIsHere Level 1
      Hi there!

      On my form I have two ComboBoxes.
      The first displays a list of countries.
      The second one, if the country selected in the first ask for, displays a list of states, provinces or republics, etc depending on the country selected.
      This second ComboBox appears or disappears driven by listeners.
      At this point, the combination of the two ComboBoxes works perfectly well.

      My problem is:
      If the first ComboBox (countries) ask for a selection of the administrative division, the user MUST select it in the second one.
      This is mandatory for the success of the registration of the order.
      In order to warn the user in case he/she didn't select the administrative division, I have tried different if/else statements based on .visible or ._visible = true or CB_TWO.selectedItem.label or CB_TWO.selectedItem.data statements but no one works.

      How can I proceed to solve this question?

      Many thanks in advance for indicating the right way!

      Best regards,

      Here is the code:

        • 1. Re: "if" related to ComboBox
          rlc5611 Level 1
          I think you are over-complicating this. If it were me, I would have a boolean variable associated to each combobox listener. Initially both those variables are false. Call the variables something like:

          CB_has_valid_selection = false;
          CB_TWO_has_valid_selection = false;

          If your listener detects a valid selection has been made from CB, change CB_has_valid_selection = true
          If a valid selection is made from CB_TWO, set that boolean to true.

          Also, changing the selected item in CB should automatically set CB_TWO_has_valid_selection = false;

          Then you can test with either

          if(CB_has_valid_selection && CB_TWO_has_valid_selection){
          //do something since both have valid selections


          if(!(CB_has_valid_selection && CB_TWO_has_valid_selection)){
          //do something since at least one does not have a valid selection

          Whichever one suits your purpose better.