4 Replies Latest reply on Oct 28, 2012 1:43 AM by GFS

    Get the value of selected (clicked) checkbox



      Get the value of selected (clicked) checkbox



           I've been going round in circles on this for some time.  I'm trying to get the value of a 'checkbox set' when a value/button has been clicked on it.  (IOW, a checkbox set with say 5 values, 3 are selected and I want to get the value of the next one clicked).

           The checkbox field is global and being used as a match field.  It is populated by the values from another field.  I'm specifically using a checkbox, because I want to be able to select multiple values.

           I have found that I can get the value of the checkbox field using onObjectValidate trigger, but it gives me ALL of the values selected in the checkbox and not just the one that's being clicked.

           I'm not against using a portal instead, but can't see a way of populating a portal with the values of the valuelist (checkbox) without them being repeated many times (as per number of records that contain the values).

           Can anyone help me with this?


        • 1. Re: Get the value of selected (clicked) checkbox

               GetValue ( checkboxField ; valueCount ( CheckboxField ) )

               will return the most recently clicked check box value.

               This is because the values selected are entered into the field in the order that the boxes were clicked. You can actually watch this happen if you make a copy of your field, change the copy back to edit box format and place it next to the check box field so that you can see the actual data in the field change as you click checkboxes.

          • 2. Re: Get the value of selected (clicked) checkbox


                 I've been using the internet since the early 90s.  I've spent a lot of time helping people in my own chosen field, but I have to say, I have never seen anyone as knowledgeable as you appear to be, contribute so much to a community.  What do you do when you're not answering questions on this forum? :) :)

                 Aside from that ... thank you for the solution.  I'll challenge your knowledge one more time though.  What if the user wants to 'deselect' a checkbox choice?  Is there any way of getting the value of the field that they deselected?


            • 3. Re: Get the value of selected (clicked) checkbox

                   That takes a bit more creativity, but it can be done.

                   Use a script with the onObjectEnter trigger to capture the previous value of the field in a global variable.

                   Then your OnObjectModify or OnObjectValidate triggered script can compare the original list of values to the new list of values to see which value is not in both lists of values. Identifying the value at that point requires either a looping script or a recursive custom function.

              • 4. Re: Get the value of selected (clicked) checkbox

                     Thanks again Phil.

                     In the end, it was overly complicated to do it this way, so I found another, better way using the replace script step via a portal.