summaryrefslogtreecommitdiff
path: root/web/src/cgi.tcl-1.10/example/evaljs.cgi
diff options
context:
space:
mode:
authorEduardo Chappa <echappa@gmx.com>2013-02-03 00:59:38 -0700
committerEduardo Chappa <echappa@gmx.com>2013-02-03 00:59:38 -0700
commit094ca96844842928810f14844413109fc6cdd890 (patch)
treee60efbb980f38ba9308ccb4fb2b77b87bbc115f3 /web/src/cgi.tcl-1.10/example/evaljs.cgi
downloadalpine-094ca96844842928810f14844413109fc6cdd890.tar.xz
Initial Alpine Version
Diffstat (limited to 'web/src/cgi.tcl-1.10/example/evaljs.cgi')
-rwxr-xr-xweb/src/cgi.tcl-1.10/example/evaljs.cgi36
1 files changed, 36 insertions, 0 deletions
diff --git a/web/src/cgi.tcl-1.10/example/evaljs.cgi b/web/src/cgi.tcl-1.10/example/evaljs.cgi
new file mode 100755
index 00000000..ea732e9d
--- /dev/null
+++ b/web/src/cgi.tcl-1.10/example/evaljs.cgi
@@ -0,0 +1,36 @@
+#!/depot/path/tclsh
+
+# This CGI script uses JavaScript to evaluate an expression.
+
+package require cgi
+
+cgi_eval {
+ source example.tcl
+
+ cgi_head {
+ title "Using JavaScript to evaluate an expression"
+
+ javascript {
+ puts {
+ function compute(f) {
+ f.result.value = eval(f.expr.value)
+ }
+ }
+ }
+ noscript {
+ puts "Sorry - your browser doesn't understand JavaScript."
+ }
+ }
+
+ cgi_body {
+ cgi_form dummy {
+ cgi_unbreakable {
+ cgi_button "Evaluate" onClick=compute(this.form)
+ cgi_text expr=Math.sqrt(2)*10000
+ puts "="
+ cgi_text result=
+ }
+ p "Feel free to enter and evaluate your own JavaScript expression."
+ }
+ }
+}