9 Replies Latest reply on Jan 23, 2012 12:47 PM by strngr12

    Values lists and radio buttons

    strngr12

      Hello,

       

      I was wondering if someone knew how I could create a radio button set such that the possible values are one, the other or neither? In other words, I want a user to be able to click one of two buttons or none of the buttons but not both of the buttons. Is this possible?

       

      Any help is apprecaited!

       

      Thanks,

       

      Dan

        • 1. Re: Values lists and radio buttons
          Mike_Mitchell

          Hi, Dan.

           

          Are you wanting there to be three radio buttons, one of which says, "None of the above" and have it deselect whichever of the other two is selected when the user clicks that third radio button?

           

          Mike

          • 2. Re: Values lists and radio buttons
            strngr12

            Hi Mike,

             

            Thanks for the quick reply.  Actually, what I was hoping to have is two buttons.

             

            The scenario is that I have a default action "add" and two other possible actions "create" and "replace."  If they do not select a button the default "add" occurs.  If they do select a button one of the other two actions occurs.

             

            However, only one of those three actions can occur so they should not be able to select both buttons - just one button (create or replace) or no button (add).

             

            Does that make sense?

             

            Thanks,

             

            Dan

            • 3. Re: Values lists and radio buttons
              Mike_Mitchell

              Dan -

               

              What you're describing is the default radio button behavior. When one radio button is selected, any other button that is selected is automatically deselected.

               

              Now, where you may have an issue is if you want all the radio buttons to be deselected by the user. This can be accomplished by clicking in the field (which will usually select one of the options) and then pressing the "Backspace" or "Delete" key. If that's too arcane for your users, you can make a button and attach a short script (or a single script step) that says, "Set Field [ "Action" ; "" ]". This will cause the contents of the field to be removed, clearing all button selections.

               

              HTH

               

              Mike

              • 4. Re: Values lists and radio buttons

                Hi Dan,

                 

                Radio buttons, by their nature, only allow one selection.  But tricky Users can hold shift and select more than one.  Two things I would suggest (both take place in the field's Options definition):

                 

                1)  Set validation to member of value list (create a custom value list with these three possible selections).  Below on 'display message' enter something such as "You cannot paste into this field or leave it empty.  Select from the radio button."

                2)  Set auto-enter by calculation as:  GetValue ( text ; ValueCount ( text ) ).  After you exit the calculation and are back at the Auto-Enter tab, UNCHECK right below where it says, "do not replace existing value of field (if any). ... where 'text' is your field name.

                 

                These two precautions should achieve what you wish.

                 

                Message was edited by: LaRetta ... so that Users can't delete the entries (leaving the field blank), check 'not empty' in the validation as well.  This will force them to return some value to the field.  This can be handled with script trigger also but if you do, still leave field-level validation in place for security.

                • 5. Re: Values lists and radio buttons

                  "The scenario is that I have a default action "add"

                   

                  BTW, I assume you mean that you have an auto-enter DATA with 'Add' as the value so that all new records begin with this value?  If you put my suggestions in place, you will need to find all records with empty value and pre-fill with 'Add' before you add the validations to the field definition.

                  • 6. Re: Values lists and radio buttons
                    strngr12

                    Hello,

                     

                    Thnks for the help!  I have done what you said, but I still have a problem.  Is there a way to make it so when a user clicks a button and then clicks it again the button deselects?  In other words, I now have two values: "create" and "replace."  If I do not see a value in that field I my script will do the default "add."

                     

                    What if a user wants to "replace" but then decides they don't want to replace but instead "add?"  I need them to be able to change their mind by clicking on the "replace" button again and having it deselect.

                     

                    Is that possible?

                    • 7. Re: Values lists and radio buttons
                      strngr12

                      Actually, this script creates an xml file for another program.  That program has a default action "add" so if there is no value "replace" or "create" in the xml then it "adds" by default.

                      • 8. Re: Values lists and radio buttons

                        No problem. :^)

                         

                        1. The default when record is created is empty instead of auto-enter data. 
                        2. Set auto-enter by calculation as:  GetValue ( text ; ValueCount ( text ) ).  After you exit the calculation and are back at the Auto-Enter tab, UNCHECK right below where it says, "do not replace existing value of field (if any). ... where 'text' is your field name.
                        3. Value list would contain "Create" and "Replace". 
                        4. Field-level validation should remain as specified 'member of value list' but remove the 'not Empty' suggestion.
                        5. Create a script with:  Set Field [ yourTable::RadioButton ; Case ( yourTable::RadioButton = Get ( ScriptParameter ) ; "" ; yourTable::RadioButton )
                        6. Create script trigger (attach it to the field itself) OnObjectModify and point to script you create in #5.  Include a script parameter of simply your field, ie just select your field from the pop-up to insert it into the calc dialog.

                         

                        This will achieve the following:

                        1. User can select Create but change their mind.  If they click Create again, it will remove the value. (handled by 5 & 6)
                        2. User can not select more than one item (handled by 2)
                        • 9. Re: Values lists and radio buttons
                          strngr12

                          Thanks so much!