user7721232
user7721232

Reputation: 5

Toggling Check Box values on worksheet change event, and setting check box values on open

Hi Google Apps Script Programmers. I have a column with checkboxes in each row. The checkboxes will be checked ON by a user if a person wants a food item. The last checkbox in the column is for NONE - if the person does not want any of the food options above it. 1) I'd like for the NONE checkbox to be marked TRUE when the Google Sheet first opens (and the other checkboxes to be turned OFF). 2) I'd like for the NONE checkbox to immediately toggle off to FALSE if any other checkbox above it is marked TRUE, and then toggle back ON if no other checkboxes are selected.

I'd prefer it if the toggling would happen automatically on the worksheet change event. Just curious as to the best way to do this.

This question pertains to the checkboxes in Getting Boolean Values from Checkboxes and Appending them as Numbers in another sheet, like Database.

Thanks much

Upvotes: 0

Views: 224

Answers (1)

arul selvan
arul selvan

Reputation: 624

See the sample solution

When "Order" is clicked the following line will reset all choices to default (False). You can do the same for all other choices and make the order qty to 1.

  //reset choices
  ordsht.getRange("D5:D10").setValues([[false],[false],[false],[false],[false],[false]]);


I feel the "none" option is not of much use. No order will be created if no option is selected. So, "none" need not be ticked (as it does not convey anything extra which is not already conveyed).

If you install "On Edit" trigger, what you want can be easily achieved. But, it will slow the order booking (as it will run in the background when each checkbox is clicked). If you want I will show you how.

Upvotes: 1

Related Questions