~ubuntu-branches/debian/stretch/alpine/stretch

« back to all changes in this revision

Viewing changes to web/src/cgi.tcl-1.10/example/evaljs.cgi

  • Committer: Bazaar Package Importer
  • Author(s): Asheesh Laroia
  • Date: 2007-02-17 13:17:42 UTC
  • Revision ID: james.westby@ubuntu.com-20070217131742-99x5c6cpg1pbkdhw
Tags: upstream-0.82+dfsg
ImportĀ upstreamĀ versionĀ 0.82+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/depot/path/tclsh
 
2
 
 
3
# This CGI script uses JavaScript to evaluate an expression.
 
4
 
 
5
package require cgi
 
6
 
 
7
cgi_eval {
 
8
    source example.tcl
 
9
 
 
10
    cgi_head {
 
11
        title "Using JavaScript to evaluate an expression"
 
12
 
 
13
        javascript {
 
14
            puts {
 
15
                function compute(f) {
 
16
                    f.result.value = eval(f.expr.value)
 
17
                }
 
18
            }
 
19
        }
 
20
        noscript {
 
21
            puts "Sorry - your browser doesn't understand JavaScript."
 
22
        }
 
23
    }
 
24
 
 
25
    cgi_body {
 
26
        cgi_form dummy {
 
27
            cgi_unbreakable {
 
28
                cgi_button "Evaluate" onClick=compute(this.form)
 
29
                cgi_text expr=Math.sqrt(2)*10000
 
30
                puts "="
 
31
                cgi_text result=
 
32
            }
 
33
            p "Feel free to enter and evaluate your own JavaScript expression."
 
34
        }
 
35
    }
 
36
}