---
name: "CGI::Toggle"
section: "3pm"
platform: "linux"
package: "gbrowse"
version: "2.56+dfsg-12"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/CGI::Toggle"
---

# CGI::Toggle(3pm)

## NAME

CGI::Toggle -- Utility methods for collapsible sections

## SYNOPSIS

use CGI ':standard'; use CGI::Toggle

print **header()**,\
   start\_html('Toggle Test'),\
   h1("Toggle Test"),\
   toggle\_section({on=\>1},p('This section is on by default'),\
   toggle\_section({on=\>0},p('This section is off by default'),\
   toggle\_section({plus\_img=\>'/icons/open.png',\
                   minus\_img=\>'/icons/close.png'},\
                  p('This section has custom open and close icons.')),\
   hr,\
   end\_html;

## DESCRIPTION

This package adds JavaScript-based support for collapsible sections by adding a single new function **toggle\_section()**.

It overrides the CGI **start\_html()** method, so CGI must be imported before bringing this module in.

### METHODS

- ($control,$content) = toggle\_section(\[\\%options\],$section\_title=\>@section\_content)

  This method takes an optional \\%options hashref, a section title and one or more strings containing the section content and returns a list of HTML fragments corresponding to the control link and the content. In a scalar context the control and content will be concatenated together.

  The option keys are as follows:

  - b\<on\>

    If true, the section will be on (visible) by default.  The default is false (collapsed).

  - b\<plus\_img\>

    URL of the icon to display next to the section title when the section is collapsed.  The default is /gbrowse2/images/plus.png.

  - b\<minus\_img\>

    URL of the icon to display next to the section title when the section is expanded..  The default is /gbrowse2/images/minus.png.

  - b\<override\>

    If false (default), the state of the section will be remembered in a session variable.  If true, the initial state will be taken from the b\<on\> option, ignoring the session.

## SEE ALSO

CGI

## AUTHOR

Lincoln Stein \<lstein@cshl.org\>.

Copyright (c) 2005 Cold Spring Harbor Laboratory

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.  See DISCLAIMER.txt for disclaimers of warranty.
