cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

How do I OnCheck, UnCheck another checkbox?

Just started and have a form to make with a lot of questions that contain 3 checkboxes each.

 

As the user can only select one of the boxes for each question and the forms text generated is decided by which boxes they ticked, how can I make it so the ticking of one box immediately unticks the other 2 in that question sector so the user doesn't have to tick and then untick it to tick another or forgets to which messes up the form?

 

I tried editting the OnCheck part of "checkbox a" to say "checkbox b".Value = false but that didn't work. I also tried editing the reset part to be if("checkbox x".Value = true, true) so that it reset if another was ticked, which worked until I did it for all 3 of them and I got an error saying you can't refer to a value dependant on your value. 

 

Anyone know how I could achieve this?

1 ACCEPTED SOLUTION

Accepted Solutions
hpkeong
Community Champion
Community Champion

Hi

 

I hope I understand what you want:

 

Create 3 CheckBox, with Survey Questions. set:

- each CheckBox.Default with a context variable

- each CheckBox.OnCheck = UpdateContext({....}); UpdateContext({...}) in PAIR (it is a must).

 

Look at my example as attached (screenshot), and it will definitely work.

 

Screenshot (498).png

 

 

 

In fact, if you are OK, why not use ListBox which allow SelectMultiple = False and you can get it done more easily.

 

Hope this helps.

 

Have a nice day.

hpkeong

View solution in original post

6 REPLIES 6
hpkeong
Community Champion
Community Champion

Hi

 

I hope I understand what you want:

 

Create 3 CheckBox, with Survey Questions. set:

- each CheckBox.Default with a context variable

- each CheckBox.OnCheck = UpdateContext({....}); UpdateContext({...}) in PAIR (it is a must).

 

Look at my example as attached (screenshot), and it will definitely work.

 

Screenshot (498).png

 

 

 

In fact, if you are OK, why not use ListBox which allow SelectMultiple = False and you can get it done more easily.

 

Hope this helps.

 

Have a nice day.

hpkeong

View solution in original post

jhuynh
Frequent Visitor

How would I do this if all checkboxes were in  a gallery? How would I reference another checkbox in a gallery?

ericonline
Community Champion
Community Champion

Did you figure out the Gallery piece? I'm having a similar issue: 

 

Scenario: 

  • "SelectAll" Checkbox outside Gallery
  • Checkbox1 placed in Gallery
  • Checkbox1 OnCheck property set to ClearCollect(selectedItems, ThisItem)
  • Checkbox1 Default property set to selectAll_Checkbox.Value
  • Checking Checkbox1 adds it to the selectedItems Gallery, no problem.
  • Checking selectAll_Checkbox puts a check in all the Checkboxes in the Gallery, but they are not added to the selectedItems Gallery. 

Thoughts on this one?

Checkbox 1 is xval1, checkbox 2 xval2, checkbox 3 xval3. The picture shows all as xval1. Everything else is correct, thank you for your example.

Hello,

 

I know it's almost an year late to repond to this question(Related to post) but maybe this will help others coming across your post. 

For the scenario that you have a Checkbox outside of a Gallery lets call it "Select All", and you want to use it to select all items from the Gallery that has a Checkbox placed in called "Checkbox1" ( *and add them to a colection called "SelectItems") :

 

For the Gallery in my case i have only 2 items Name and File:

-Name.Text=Label for Name in Gallery

-DisplayFileName.Text= Label for File in Gallery


Set up as it follows:

1.SelectAll Checkbox outside Gallery:

OnCheck:   ForAll(Gallery.AllItems, Collect(SelectItems, {Name: Name.Text, File: DisplayFileName.Text}))
OnUncheck: Clear(SelectItems)

 

2.Checkbox1 placed in Gallery:

OnCheck:  Collect(SelectItems, {Name: Label2.Text, File: DisplayFileName.Text})
OnUncheck: Clear(SelectItems)
Default: SelectAll.Value

To test that it collects all selected checkboxes, I created a Blank Vertical Gallery and set its Items property to : SelectItems, and add 2 labels for Name and File, and set up for each on the Text property: ThisItem.File for the File label, and ThisItem.Name for the Name label.

Hope it helps! 🙂
 

AlisterT
Advocate I
Advocate I

Hey All,

 

I think I have found an easier way of doing this. I have 2 checkboxes. CHK1 & CHK2.

 

CHK1.OnCheck = reset(CHK2)
CHK2.OnCheck = reset(CHK1)

 

Seems to work OK for me.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,016)