Skip to content
Advertisement

Show all googlesheets when clicking outside

I am currently working on project where I have two sheets “Sheet 1” & “Sheet 2”. i have developed two html button named “Sheet 1” & Sheet 2. When user clicks “Sheet 1”-> it hides Sheet 2. Similarly, if the user clicks “Sheet 2”-> it hides Sheet 1. Currently button is working as per the below working if user clicks Sheet 1 and “it hides sheet 2” and when when user wants to click on “sheet 2” button, sheet 2 is already hidden and doesn’t show.

JavaScript

How do I show sheet “Sheet2” when Sheet2 button is clicked after clicking sheet1 button that hides “Sheet 2”?

Advertisement

Answer

Explanation:

  • The main issue is that you have 2 functions with the same name.

  • Your general logic is correct, but to make your steps more clear you could check first if a sheet is hidden, and then unhide it:

    JavaScript
  • The last suggestion is optional. You can omit the if statements and use only ws.showSheet() but it should be before ws2.hideSheet(), since you must have at least one sheet open in the UI.

Solution:

Don’t forget to modify the buttons to attach them the new function names:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement