blob: ea732e9d9df7f9a3c85c8015c33ea9daaa497629 (
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
|
#!/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."
}
}
}
|