2 Replies Latest reply on Mar 13, 2007 7:13 AM by ajrobson

    How to keep track of which checkboxes are checked

      I have 21 checkboxes on a scene and want a user to have to pick at least four of them, i will then use the ticked checkboxes to bring data back from a database. My question is how do i keep track of which checkboxes are clicked so i can put them in to a sql statement like this?

      select * from table where title in (checkbox1, checkbox2, checbox13);

      And how do i make sure the user has picked four boxes before being allowed to leave the current frame?

      EDIT: sorry this is probably in the wrong forum it should go under basics, but instead of posting the thread there can someone please reply to it here, thank you.
        • 1. Re: How to keep track of which checkboxes are checked
          Level 7
          Somewhere you have a control that allows the user to "submit" their
          chosen options or navigate. This seems a sensible thing to attach
          validation logic to.
          You have a number of checkboxes, but you don't say what type they are
          (#flashComponent, #OSControls, #button, ...) The type of control will
          govern the syntax of the script attached to them, but I would suggest
          adding a behavior to your navigation control, something like:
          on mouseUp me
          tList = []
          _movie.sendAllSprites(#mCollectCheckedBoxes, tList)
          if count(tList) < 4 then
          -- not enough boxes checked
          -- present an alert, or ...
          end if

          -- walk the list building your SQL statement:
          repeat with aTitle in tList

          end repeat

          -- navigate:

          You could then attach a behavior to each of the text boxes that will
          respond to the #mCollectCheckedBoxes message:
          on mCollectCheckedBoxes me, aList
          -- syntax will vary depending on type:
          -- if the sprite is checked
          if sprite(me.spriteNum).member.hilite = 1 then
          -- add its text to the passed list
          end if
          • 2. Re: How to keep track of which checkboxes are checked
            ajrobson Level 1
            i am using flash component checkboxes, i tried to come up with my own way to do this i am doing different:

            on CheckBoxState -- name of custom handler
            TickedBoxes = [] -- a empty list will be filled where ever a checkbox is ticked
            CheckBoxNames = ["dr no", "from russia","goldfinger", "thunderball", "you only live" ]
            -- the above is a list containing the names of all my checkboxes
            repeat with i = 1 to 5 - repeat for each checkbox
            CurrentCheckbox = CheckBoxNames -- used to keep track of which box is checked this sets currentcheckbox to value of i, i is a checkbox from checkboxname list
            if the hilite of member(CurrentCheckbox) then -- if currentcheckbox hilite is true (checked)...
            append(TickedBoxes, CurrentCheckbox) -- ... add currentcheckbox to the tickedboxes list
            end if
            end repeat -- end repeat
            return TickedBoxes -- return the list of checked boxes

            on mouseUp me -- on mouse click
            choosenBoxes = me.CheckBoxState() -- chosenboxes is a variable calls the handler on it
            -- will put sql here

            this is the only script i have which is attahced to my submit button, but for some reason when i try to trace the results in the message window it always return void can anybody tell me what i am doing wrong?