Ok, taking just the first 2 points try this to see if I understand you correctly
#!/usr/bin/perl
use strict;
use CGI::Ajax;
use CGI;
my $cgi = new CGI();
my $pjx = new CGI::Ajax(
'function1' => \&myfunction1,
'function2' => \&myfunction2,
# 'skip_header' => 1
);
print $pjx->build_html($cgi,\&main,
{-charset=>'UTF-8', -expires=>'-1d'});
sub main {
my $html = <<EOT;
<HTML>
<HEAD><title>CGI::Ajax Example</title></HEAD>
<BODY>
<div id="div2_text">Chapter = </div>
BOOK
<select id="select1" onchange="function1(['select1'],['div1_text'],
+'POST'); ">
<option value="">Select Book</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select></br>
CHAPTER
<div id="div1_text"></div>
</BODY>
</HTML>
EOT
return $html;
}
sub myfunction2 { return "Chapter = ".shift };
sub myfunction1 {
my $book = shift;
my @chap = (undef,['1A','1B','1C'],
['2A','2B','2C','2D'],['3A','3B']);
my $option;
for (@{$chap[$book]}){
$option .= qq!<option value="$_">$_</option>!;
}
return qq!
<select id="select2" onchange="function2(['select2'],['div2_text'],
+'POST'); ">
$option
</select>!;
};
poj
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.