4 Replies Latest reply on May 7, 2007 3:31 PM by pajaroplus

    tricky for loop

    Optikalefx Level 1
      so, this works
      if (my_cb1.selectedItem.data == 1 || my_cb2.selectedItem.data == 1 || my_cb2.selectedItem.data == 1 || my_cb3.selectedItem.data == 1 || my_cb4.selectedItem.data == 1)

      but i wanna put into a for loop because i dont know how many cbs there are gonna be
      so i tried this

      for (k=1; k<=useRows; k++) {
      if (eval("my_cb"+k+".selectedItem.data") == 1 )
      }

      that doesnt work

      i tried this

      L = 1;
      for (k=1; k<=useRows; k++) {
      L+=k
      if (eval("my_cb"+k+".selectedItem.data") == 1 || if (eval("my_cb"+L+".selectedItem.data") == 1 ))
      }

      also doesnt work.

      something has got to be wrong with my eval() but what...
        • 1. Re: tricky for loop
          MurMeeKeer Level 1
          Hi,

          This is working fine. Is this your requirement?
          • 2. Re: tricky for loop
            Optikalefx Level 1
            thanks, but its not quite working.

            whats more or less happening here is there are X number of combo boxes with 3 choices. The first choice is always Game # and the 2nd is a team, and the 3rd is a team. and then those 3 choices are there for each combo box. I have the data for choice "game #" to 1. So i want an error check, before you submit the data you want to make sure that none of the combo boxes has data as 1, or the combo box doesnt have a team selected. I just want to make sure that every combo box has a team selected. Soo i want to make an error message that comes up if ANY box doesnt have a team selected.

            the code that you gave gives the error messge if they all are set to game #. but if 4 are set to teams, and one is set to game # then it doesnt work. Thats why my if this or this or this or this or this method worked because it was an or statement, as in if any one box had selected data of 1 then it would give the error. I would use a while loop like i do in C but god forbid a while loops doesnt freeze flash.
            • 3. Re: tricky for loop
              Optikalefx Level 1
              I guess the only way is to make an if blank or blank or blank or blank for the total possible number of choices?

              i thought it could be done in a for loop, but there doesnt seem to be a way.
              • 4. Re: tricky for loop
                pajaroplus Level 1
                MurMeeKeer gave you the answer, he only forgot a break after the trace:

                trace("Yes");
                break;