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
Level 10

Re: How do I OnCheck, UnCheck another checkbox?

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

5 REPLIES 5
hpkeong
Level 10

Re: How do I OnCheck, UnCheck another checkbox?

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
Level: Powered On

Re: How do I OnCheck, UnCheck another checkbox?

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

Super User
Super User

Re: How do I OnCheck, UnCheck another checkbox?

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?

Phillip-JCI
Level: Powered On

Re: How do I OnCheck, UnCheck another checkbox?

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.

Highlighted
IoanaG
Level: Powered On

Re: How do I OnCheck, UnCheck another checkbox?

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! 🙂
 

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,698)