Toggling forms with a single function

I have a page that has 4 <a> tags. Each tag is then associated with a toggle function. I have basically written each one like so


The problem is, I have four of these. Is there a way to write one function that will toggle each form when it is clicked, and when another one is clicked, close the previous one? I read that I need to set data attributes to each form? Looking for any guidance.


Does the link above help at all?