Creates a CGI object. Level may be one of the following options. If one of the HTML levels is specified, the following methods are defined for generating output conforming to that level −
query − No HTML output generated
html3 − HTML3.2
html4 − HTML4.0 Strict
html4Tr − HTML4.0 Transitional
html4Fr − HTML4.0 Frameset
2
CGI::escape( str)
Escapes an unsafe string using URL-encoding.
3
CGI::unescape( str)
Expands a string that has been escaped using URL-encoding.
4
CGI::escapeHTML( str)
Escapes HTML special characters, including: & < >.
5
CGI::unescapeHTML( str)
Expands escaped HTML special characters, including: & < >.
6
CGI::escapeElement( str[, element...])
Escapes HTML special characters in the specified HTML elements.
7
CGI::unescapeElement( str, element[, element...])
Expands escaped HTML special characters in the specified HTML elements.
8
CGI::parse( query)
Parses the query and returns a hash containing its key-value pairs.
9
CGI::pretty( string[, leader=" "])
Returns a neatly formatted version of the HTML string. If leader is specified, it's written at the beginning of each line. The default value for leader is two spaces.
10
CGI::rfc1123_date( time)
Formats the data and time according to RFC-1123 (for example, Tue, 2 Jun 2008 00:00:00 GMT).
CGI Instance Methods
Sr.No.
Methods with Description
1
c[ name]
Returns an array containing the value of the field name corresponding to name.
2
c.checkbox( name[, value[, check = false]])
c.checkbox( options)
Returns an HTML string defining a checkbox field. Tag attributes may be specified in a hash passed as an argument.
3
c.checkbox_group( name, value...)
c.checkbox_group( options)
Returns an HTML string defining a checkbox group. Tag attributes may be specified in a hash passed as an argument.
4
c.file_field( name[, size = 20[, max]])
c.file_field( options)
Returns an HTML string defining a file field.
5
c.form([ method="post"[, url]]) { ...}
c.form( options)
Returns an HTML string defining a form. If a block is specified, the string produced by its output creates the contents of the form. Tag attributes may be specified in a hash passed as an argument.
6
c.cookies
Returns a hash containing a CGI::Cookie object containing keys and values from a cookie.
7
c.header([ header])
Returns a CGI header containing the information in header. If header is a hash, its key-value pairs are used to create the header.
8
c.hidden( name[, value])
c.hidden( options)
Returns an HTML string defining a HIDDEN field. Tag attributes may be specified in a hash passed as an argument.
9
c.image_button( url[, name[, alt]])
c.image_button( options)
Returns an HTML string defining an image button. Tag attributes may be specified in a hash passed as an argument.
10
c.keys
Returns an array containing the field names from the form.
11
c.key?( name)
c.has_key?( name)
c.include?( name)
Returns true if the form contains the specified field name.
12
c.multipart_form([ url[, encode]]) { ...}
c.multipart_form( options) { ...}
Returns an HTML string defining a multipart form. If a block is specified, the string produced by its output creates the contents of the form. Tag attributes may be specified in a hash passed as an argument.
13
c.out([ header]) { ...}
Generates HTML output. Uses the string produced by the block's output to create the body of the page.
14
c.params
Returns a hash containing field names and values from the form.
15
c.params = hash
Sets field names and values in the form using a hash.
Returns an HTML string defining a text area. If a block is specified, the string produced by its output creates the contents of the text area. Tag attributes may be specified in a hash passed as an argument.
HTML Generation Methods
You can create any HTML tag by using the corresponding HTML tag name along with any CGI instance. For example −