10 Replies Latest reply on Jul 25, 2012 5:06 PM by CharlesLuong

    Help with check box value list with "Other:" and free text

    CharlesLuong

      Title

      Help with check box value list with "Other:" and free text

      Post

      Hello, currently for check box fields where there is a need to select "Other: _____________" and allowing the user to provide free text input, I have an additional editable text field below the check box value list allowing the user to include details for 'Other:'.

       

      Field 1 (check box value list)

      [ ] red

      [ ] blue

      [ ] green

      [ ] other (specify below)

       

      Field 2 (free text box)

      other: __________________

       

      Ideally what I am hoping is possible is when the user checks off 'Other' in the check box field, a pop up dialog box allowing them to enter some text. Then the original check box value list would be updated to include added free text along with the 'other' value checked.

      New Field 1

      [ ] red

      [ ] blue

      [ ] green

      [X] other : orange

       

      Also, should the user changed their mind and removes the 'other' checked item that the value list returns back to their original values.

      Field 1

      [ ] red

      [ ] blue

      [ ] green

      [ ] other

       

      Can this be accomplished?

      Thank you!

        • 1. Re: Help with check box value list with "Other:" and free text
          philmodjunk

          There is an "other" option you can specify on the data tab of the inspector when you set up your field to use check boxes. This does all but display the value entered by the user as the "other" value.

          If you have FileMaker Advanced, you could add a custom function that returns any value in your checkbox formatted field that is not a member of it's value list and use that in a calculation field to display the value.

          If you do not have advanced, your options are less elegant, but the same result can be done with scripting and script triggers. You might consider defining a separate field for each check box with single value checkboxes. Then an OnObjectModify trigger on the "other" field could perform a script that pops up a custom dialog with in input field for entering the "other" value and then that field could be placed to the right of the Other checkbox in order to display the value thus entered.

          • 2. Re: Help with check box value list with "Other:" and free text
            CharlesLuong

            Thank you as always Phil. After I posted my question and went back to the Value List option, it was then that I realized the option 'allow entry of other values'.

             

            I have FM Advanced. How would I go about doing what you suggested?

            Thank you.

            • 3. Re: Help with check box value list with "Other:" and free text
              philmodjunk

              The trick is for the CF to use recursion to loop through each selected value until it either reaches the return of the list or a value that is not in the original value list. You can probably find and download a CF that does this from one of the sites that list custom functions.

              I'd use this in a calculation field:

              RemoveSubList ( YourCheckboxField ; ValueListItems ( Get (FileName) ; "YourValueListNameInQuotes" ) )

              I found this CF in one of my DB files, not sure if I created it or copied it from somewheres:

              //  RemoveSubList ( SourceList ; SubList )
              //
              // Return a list of all values in SourceList that are not also listed in SubList
              // SourceList: A return separated list of values
              // SubList: a Return separated list of values to be removed from SourceList

               Let ( [ ListItem = GetValue ( SubList ; 1 ) ;
                         SubListRemanent = RightValues ( SubList ; ValueCount ( SubList ) - 1 ) ;
                         FilteredSourceLista = Substitute ( ¶ & SourceList & ¶ ; ¶ & ListItem & ¶ ; ¶ ) ;
                         FilteredSourceListB = Middle ( FilteredSourceLista ; 2 ; Length ( FilteredSourceLista ) -2 )
                        ] ;
                      Case ( IsEmpty ( SubList ) ; SourceList ;
                                 RemoveSubList ( FilteredSourceListB ; SubListRemanent )
                               ) // case
                       ) // Let

              • 4. Re: Help with check box value list with "Other:" and free text
                CharlesLuong

                Ah ok, I understand now. I'll give it a try.

                 

                Thank you very much!

                • 5. Re: Help with check box value list with "Other:" and free text
                  CharlesLuong

                  So I added the above CF, created a separate calculated field as per your instructions. The results returned in the calculated field displaying only what was entered when I selected Other in the checkbox field and added the free text. Worked great!

                  Is it possible to update my checkbox field to now include what's in the calculated field as part of the entire list of checkboxes? 

                   

                  Example - Current Setup

                  CheckBox Field

                  [ ] Red

                  [ ] Blue

                  [X] Green

                  [X] Other...

                   

                  Calculated Field Result

                  Orange

                   

                  I can just move the calculated field on my layout to sit to the right of the 'Other...' checkbox to simulate the following:

                  [ ] Red

                  [ ] Blue

                  [X] Green

                  [X] Other...Orange

                   

                  Let's say I now want to remove what was entered for 'Other...'. I click on the 'Other...' checkbox and the 'Other...' pop up dialog displays:

                  Green

                  Orange

                  Is it possible to only display 'Orange' instead of all checked values? If not, the user may need to live with it.

                   

                  So I delete 'Orange' from the pop up dialog and leave Green there, click OK. The checkboxfield now displays:

                  CheckBox Field

                  [ ] Red

                  [ ] Blue

                  [X] Green

                  [ ] Other...

                   

                  Close to what I want but not as clean and tidy as I'd like.

                   

                   

                  Maybe can I have it do this instead?

                  CheckBox Field

                  [ ] Red

                  [ ] Blue

                  [X] Green

                  [X] Other...Orange

                  [ ] Other...

                   

                  Basically, what you see above is take the original valuelist, add what was added to make a new valuelist, then remove what was entered for 'Other...'. An entirely new valuelist is then created and displayed.

                  Should the user want to Remove the existing 'Other...Orange' entry, unchecking it would remove it from the list, returning the valuelist back to the original checkbox values:

                  CheckBox Field

                  [ ] Red

                  [ ] Blue

                  [X] Green

                  [ ] Other...


                  I hope there's a solution or maybe you have a better idea?

                   

                  Thank you!

                  • 6. Re: Help with check box value list with "Other:" and free text
                    philmodjunk

                    It will create issues. The main one is that your check box field has only a fixed size. As you add values--which can be done if you draw your values from fields in a table of values, your list will get too long and not all will be visible.

                    There is, however, a way to do this if you use a portal to simulate the group of checkboxes. It looks and functions just like a field with a set of checkboxes, but since it's a portal, you can include a scroll bar so that users can scroll to see additional options once the list has gotten too long to view all of the options. It also allows you to use something other than the "plain vanilla, x inside a box" format for the check box as you would use a text character to represent the "tick mark" inside the check box.

                    Does this sound like a possibility?

                    Let me know and I'll post a description of the method and, if I can find it, a demo file that I created some time ago that illustrates this trick.

                    The other option, BTW becomes something that can be handled by a script that adds new records to this table. You can even add a "manage" or "edit" button that pops up the entire list where you can add/remove/change the values used with the "check boxes".

                    • 7. Re: Help with check box value list with "Other:" and free text
                      CharlesLuong

                      As for the checkbox field size, I'm thinking that it would only include one more added 'Other...' value instead of many more 'Other...' values. While it would allow the user to add more than one 'Other...', in my situation, it would not be the case. If there was another 'Other...' value, they would just delete the existing one and add another 'Other...' value to the list. Or even better is that if they choose to add another 'Other...' value that it removes the existing 'Other..' value from the list. The previous 'Other...' value would be stored in a field as a marker to be used to remove it from the ValueList?

                      In any event, the portals setup might be a possible option. I would love to see your demo file of it.

                      I would assume with the portal setup I'd be stuck with a vertical checkbox layout instead of a horizontal one?

                      [ ] Red  [ ] Blue  [X] Green  [X] Other...Orange

                       

                      Thank you!

                      • 8. Re: Help with check box value list with "Other:" and free text
                        philmodjunk

                        Actually, a horizontal portal is possible, but it takes some extra fiddling and the flexible size issue become horizontal and setting up buttons to "scroll" become even more work as you'd need buttons and scripts for that. But it can be done if you want to. You use a series of one row portals side by side, each set up to display a different "initial row".

                        There's a build in danger to what you describe with checkboxes and changing the values in the value list used for the check boxes. If you have Red, Blue, Green as your list of values and then edit the value list to get Red, Blue, Purple, any records with Green selected still store "Green" in the checkbox field, but without a checkbox for "Green" the value is invisible. But since it is still there, it can affect the results of finds and other actions that reference the value of this field. I recommend that any actions that enable the user to modify the values in a value list used for checkboxes or radiobuttons include a script that updates the data stored in the field to be consistent with the new values in the value list.

                        In your case it sounds like you could only have at most two values not present in the value list (The first "other" and the second "other") so this might be pretty easy to manage.

                        I actually have two files that demo this trick:

                        https://www.dropbox.com/s/ti8vep64h67mtj2/CheckboxWScrollBar.fp7

                        https://www.dropbox.com/s/oyir7cs0yxmbn6i/ManyToManywDemoWExtras.fp7

                        • 9. Re: Help with check box value list with "Other:" and free text
                          CharlesLuong

                          Thanks for the demo file but it's not exactly what I had in mind. Nonetheless, I think I can use the checkbox code to simulate the layout the way I need it. It's more coding in the background but I think I can achieve the desired end result on the front end for the user.

                           

                          Otherwise, what I'm thinking of doing is this:

                          Have the default checkbox without 'allow entry of other values' enabled.

                          Include another checkbox field next to the first checkbox that only has a value of 'Other..'.

                          Have a third field, free text, next to the 2nd Other only checkbox field.

                          The coding that I'm planning to use is that if the user needs to add a 'Other...', the user would simply start typing in the free text field. As they enter the free text field, a script trigger would mark the 2nd Other only checkbox. Should the user changed their mind and leave the free text field empty, an on object exit script would uncheck the 2nd Other only checkbox. Additional code to also monitor the 2nd Other checkbox to wipe the contents of the free text field should the user unchecks that checkbox. I hope I haven't confused anyone with that explanation.

                          Yes it's messy from a coding perspective hence I was looking forward to be able to update the original ValueList on demand as needed. Should I need to print a report with the contents of the entire setup, I'm thinking of just concantenating the two fields (2nd Other and free text) to marked selections in the 1st value list field.

                          I'll return with my findings.

                          Thank you again for your help to get the brain juices going!

                          • 10. Re: Help with check box value list with "Other:" and free text
                            CharlesLuong

                            I'm back to report that I did get the results I was aiming for, albeit not what I originally wanted but as a workaround. I used my quick and dirty method.

                             

                            Thank you again for your prompt replies and suggestions Phil! I really appreciate it!