summaryrefslogtreecommitdiff
path: root/web/src/cgi.tcl-1.10/example/form-tour.cgi
blob: 7e5e49d562bd17bab5f6ac6e2a5baa58d9862465 (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/depot/path/tclsh

# This is a CGI script that shows a selection of form elements
# This script doesn't actually DO anything.

package require cgi

cgi_eval {
    source example.tcl

    cgi_title "A Tour of Form Elements"

    cgi_body {
	form form-tour-result {
	    h4 "Samples of image button"
	    cgi_put "image as button"
	    cgi_image_button "=http://www.nist.gov/msidimages/title.gif"
	    br
	    cgi_put "image as button (and will return coords)"
	    cgi_image_button "Map=http://www.nist.gov/public_affairs/gallery/fireseat.jpg"

	    h4 "Samples of submit button"
	    cgi_submit_button
	    cgi_submit_button ="Submit"
	    cgi_submit_button "=Submit Form"
	    cgi_submit_button "Action=Pay Raise"

	    h4 "Samples of reset button"
	    cgi_reset_button
	    cgi_put "Default Reset Button"
	    br
	    cgi_reset_button "Not the Default Reset Button"
	    cgi_put "Not the Default Reset Button"

	    h4 "Samples of radio button"
	    cgi_radio_button "version=1"
	    cgi_put "Version 1"
	    br
	    cgi_radio_button "version=2"
	    cgi_put "Version 2"
	    br
	    cgi_radio_button "version=3" checked
	    cgi_put "Version 3"

	    br
	    foreach x {A B C D} {
		cgi_radio_button "$x=" checked_if_equal=B
		cgi_put "$x"
		br
	    }

	    h4 "Samples of checkbox"
	    cgi_checkbox VegieList=carrot
	    cgi_put "Carrot"
	    br
	    cgi_checkbox VegieList=rutabaga checked
	    cgi_put "Rutabaga"
	    br
	    cgi_checkbox VegieList=
	    cgi_put "Vegie"

	    h4 "Samples of textentry"
	    set Foo0 "value1"
	    set Foo1 "value1"
	    cgi_text Foo0
	    br;cgi_text Foo1=
	    br;cgi_text Foo2=value2
	    br;cgi_text Foo3=value2 size=5
	    br;cgi_text Foo4=value2 size=5 maxlength=10
	    br;cgi_text Foo5=value2 size=10 maxlength=5
	    br;cgi_text Foo6=value2 maxlength=5

	    h4 "Samples of textarea"

	    set value "A really long line so that we can compare the\
		    effect of wrap options."

	    set Foo10 "value1"
	    set Foo11 "value1"
	    cgi_textarea Foo10
	    br;cgi_textarea Foo11=
	    br;cgi_textarea Foo12=$value
	    br;cgi_textarea Foo13=$value         rows=3
	    br;cgi_textarea "Foo14=default wrap" rows=3 cols=7
	    br;cgi_textarea Foo15=wrap=off       rows=3 cols=7 wrap=off
	    br;cgi_textarea Foo16=wrap=soft      rows=3 cols=7 wrap=soft
	    br;cgi_textarea Foo17=wrap=hard      rows=3 cols=7 wrap=hard
	    br;cgi_textarea Foo18=wrap=physical  rows=3 cols=7 wrap=physical
	    br;cgi_textarea Foo19=wrap=virtual   rows=3 cols=7 wrap=virtual

	    h4 "Samples of select as pull-down menu"
	    cgi_select Foo {
		cgi_option one selected
		cgi_option two
		cgi_option many value=hello
	    }

	    h4 "Samples of select as scrolled list"
	    cgi_select FooList multiple {
		cgi_option one selected
		cgi_option two selected
		cgi_option many 
	    }
	    br
	    cgi_select FooList multiple size=2 {
		cgi_option two selected
		cgi_option three selected
		cgi_option manymore
	    }
	    br
	    # choose "selected" dynamically
	    cgi_select FooList multiple size=5 {
		foreach o [info comm] {
		    cgi_option $o selected_if_equal=exit
		}
	    }
	    h4 "Samples of isindex"
	}
	cgi_isindex
	cgi_isindex "prompt=Enter some delicious keywords: "
    }
}