File: x11cgi_nodbi.pl

package info (click to toggle)
libdbd-informix-perl 2003.04-3
  • links: PTS
  • area: contrib
  • in suites: etch, etch-m68k, sarge
  • size: 1,232 kB
  • ctags: 467
  • sloc: perl: 7,349; ansic: 5,340; sh: 184; makefile: 58
file content (55 lines) | stat: -rwxr-xr-x 1,494 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl -w
#
# @(#)$Id: x11cgi_nodbi.pl,v 100.1 2002/02/08 22:50:14 jleffler Exp $
#
# Simple example of self-populating (self-regenerating) CGI Form
# Adapted from CGI.pm documentation; revised to work with CGI::Apache.
#
# Copyright 1998 Jonathan Leffler
# Copyright 2000 Informix Software Inc
# Copyright 2002 IBM

use strict;
use Apache;
use CGI::Apache;

my $q = new CGI::Apache;

my $clear = ($q->param('reset')) ? 1 : 0;
my @rainbow = ('red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet');

# CGI::Apache doesn't support a suitable delete_all or Delete_all...
map { $q->delete($_); } $q->param if ($clear);

print	$q->header,
		$q->start_html('A Simple Example'),
		$q->h1('A Simple Example'),
		$q->start_form,
		"What's your name? ",
		$q->textfield(-name=>'name', -default=>'', -override=>$clear),
		$q->p,
		"What's the combination?", $q->p,
		$q->checkbox_group(	-name=>'words', -override=>$clear,
						-value=>['eenie', 'meenie', 'minie', 'moe'],
						-default=>['eenie', 'meenie']),
		$q->p,
		"What's your favourite colour? ",
		$q->popup_menu( -name=>'colour', -override=>$clear,
					-value=>[@rainbow]),
		$q->p,
		$q->submit,
		$q->submit(-name=>'reset', -value=>'Clear Form'),
		$q->end_form,
		$q->hr;

if ($q->param('name'))
{
	print	"Your name is ", $q->em($q->param('name')),
			$q->p,
			"You think the keywords are: ",
			$q->em(join(", ", $q->param('words'))), $q->p,
			"Your favourite colour is ",
			$q->em($q->param('colour')),
			$q->hr;
}