File: pjx_change_encoding.pl

package info (click to toggle)
libcgi-ajax-perl 0.707-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 284 kB
  • sloc: perl: 1,669; makefile: 2
file content (44 lines) | stat: -rwxr-xr-x 869 bytes parent folder | download | duplicates (5)
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
#! /usr/bin/perl -w

use strict;
use CGI::Ajax;
use CGI;

my $func = sub {
  my $input = shift;
  return "got input: $input " ;
};


sub Show_HTML {
my  $html = <<EOT;

<html>
<head><title>CGI::Ajax Example</title>

</head>
<body>
<form>
Enter Something:&nbsp;
  <input type="text" name="val1" id="val1" size="6" onkeyup="jsfunc( ['val1'], 'result' ); return true;"><br>
Enter Something:&nbsp;
    <hr>
    <div id="result" style="border: 1px solid black;
          width: 440px; height: 80px; overflow: auto">
    </div>

</form>
</body>
</html>

EOT

}

my $cgi = new CGI();  # create a new CGI object
my $pjx = new CGI::Ajax( 'jsfunc' => $func );
# the default encoding for CGI::Ajax is encodeURIComponent;
# if this causes problems, you can use escape or your own javascript
# function;
$pjx->js_encode_function('escape');
print $pjx->build_html($cgi,\&Show_HTML);