9 Replies Latest reply on Jan 11, 2013 10:31 AM by philmodjunk

    Help with multiple checkboxes

    NathanVeitch

      Title

      Help with multiple checkboxes

      Post

      Hi There,

      I'm having a bit of trouble with some checkboxes that I am using. I have 3 checkboxes on my layout, each checkbox is for a matching field. I need to figure out the script to run that will check to see if any of the checkboxes are selected, and if any are selected, then the navigation must move to the last field in the portal. 

      I tried running a script trigger on object enter that has an If statement in it that I thought would check all 3 boxes, but it just is not working properly. I think I am getting confused between 'and', 'or' and '&'. I tried all 3 and well none of them worked the way I needed them to work. I thought that with the 'and' I could have an if statement like, 

      If [ fieldA = "1" and fieldB = "1" and fieldC = "1"]
      show custom dialog ....
      Set Field [""]
      Exit Script
      Else
      Exit Script
      End If

      Then set that as an OnObjectEnter script trigger, but alas, no joy. Then I tried replacing the 'and' with '&' and that also didn't really help and I also tried replacing it with 'or' and the = with not= (well the sign in the calculation box for not =), and still no joy. 

      It seems to work fine the very first time I run the script, but if I select the same box again, or if I select one of the other boxes, sometimes it works and sometimes it doesn't. I had a look in Data Viewer and it seems to activate the checkbox the moment I press on it and I think that is where I am going wrong. 

      In another solution I worked on a few months ago I had a similar issue and what I ended up doing was having a hidden field in the portal which would get a value if any of the checkboxes are selected, and then the OnObjectEnter script trigger would check that field and go according to that. I am about to do that again, but thought maybe there is an easier way to do this. Or would it be easier to use the hidden field option, like I did in a previous solution I worked on?

      Thanx for any advice 

        • 1. Re: Help with multiple checkboxes
          philmodjunk

               OnObjectEnter triggers BEFORE the data is changed by your mouse click. Consider OnObjectModify for checkbox and radio button formatted.

               I'm a big confused by your post. You stated: I need to figure out the script to run that will check to see if any of the checkboxes are selected, and if any are selected, then the navigation must move to the last field in the portal.

          If selecting "Any" of the three checkboxes should produce this result, you want OR not AND (and & is used for something else).

          And set field will not "go to the last field in the portal". Do you want to go to the last field in the current portal row or to the last portal row?

          If you want to go to the last field in the current portal row (assumes that your check boxes are part of the portal row), go to field can be used to put the focus in that field.

          • 2. Re: Help with multiple checkboxes
            NathanVeitch

                 Hi Phil,

                  

                 Sorry about that confusion, I see that I left off the last line in the script I posted. The last line of the If statement was supposed to have a Go to Field [Table::Field]. So the thought behind the script is that if one of the checkboxes is selected, then if they select another checkbox, it  displays a message saying that there is already a field selected and then jumps to the last field of the portal row. They will need to de-select the selected checkbox before they can change there mind. 

                  

                 That is the thought anyway :$ Would it be easier to use a hidden field in the portal row that would be set should one of the checkboxes be selected. Then the script could just check that one field on object enter and if it has a value then display the message, or is there a better way to do this?

            • 3. Re: Help with multiple checkboxes
              philmodjunk

                   If your fields are of type number, use:

              If [ fieldA or fieldB or fieldC ]

                   If your fields are of type text, use:

              If [ fieldA = 1 or fieldB = 1 or fieldC = 1]

                   And since you want to check the values before the mouse click can modify one, use OnObjectEnter for the trigger and end your script with:

                   Exit Script [False] If you want to prevent the mouse click from modifying the value.

                   But wouldn't a single field with three radio button values make for a simpler interface? (That limits the user to being able only to select one of the three values without nearly as much scripting.) (May need to use a little bit of scripting or a field validation rule to prevent shift clicks from selecting two values...)

              • 4. Re: Help with multiple checkboxes
                NathanVeitch

                     I was thinking of using radio buttons, but the checkboxes are each for there own fields. I need to either get no vlaue or a 1 for only one of the 3 check boxes and then I have to send that to a SQL DB. That is going to be my next post as I am only just now learning about SQL. 

                      

                     I have set the fields to Number, so I will try the first option as you suggested and let you know how that goes. 

                      

                     Thanx again for the advice :)

                • 5. Re: Help with multiple checkboxes
                  philmodjunk

                       You can still use a radio button field. To get three separate fields to send to that other DB, you can define calculation values that reference the radio button field and return a value only if that value is selected.

                       Say you have radio button values: Apple, Orange, Kiwi

                       cApple might be defined as: RadioButtonField = "Apple" and set it to return a number data type.
                       cOrange might be: RadioButtonField = "orange"
                       cKiwi: RadioButtonField = "Kiwi"

                  • 6. Re: Help with multiple checkboxes
                    NathanVeitch

                         Ok, wasn't aware you could do that. 

                          

                         I have however got it working :) I tried what you suggested but I kept running into problems when I tried to selected the checkbox. What I tried now and it is working like a charm, is using script parameters. I made a If, Else If, Else statement and in then used parameters for the check boxes. So if they select a checkbox, it will just clear the other 2 checkboxes automatically and move to the last field. :) 

                          

                         Thanx again Phil for the tips.

                    • 7. Re: Help with multiple checkboxes
                      philmodjunk

                           My main issue with using checkboxes here is that it violates a user interface convention that checkboxes permit selecting any and all combinations while radio buttons limit you to just one selected value.

                      • 8. Re: Help with multiple checkboxes
                        NathanVeitch

                             I see your point. I have changed them to radio buttons and now it looks a lot better :)

                        • 9. Re: Help with multiple checkboxes
                          philmodjunk

                               Note that with radio button fields, you can use this validation calculation:

                               ValueCount ( Self ) < 2

                               to limit the user to only one selection even if they know that they can hold down the shift key to select two values.