How to write code for toggle

Hey Shiva @ShivaRaju, maybe try checking the solution from the previous post here about handling the toggle button.