I would like to add functionality to a separate button(s)/AJAX call that would come from a different form input, be associated to a separate Perl function, and direct its output to a different div

It's difficult to understand what you mean without a complete script so maybe this simple example will help.

#!/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="div1_text">Number = </div> <div id="div2_text">Letter = </div> <select id="select1" onchange="function1(['select1'],['div1_text'], +'POST'); "> <option value="">Select Number</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> <select id="select2" onchange="function2(['select2'],['div2_text'], +'POST'); "> <option value="">Select Letter</option> <option value="A">A</option> <option value="B">B</option> <option value="C">C</option> </select> </BODY> </HTML> EOT return $html; } sub myfunction1 { return "Number = ".shift }; sub myfunction2 { return "Letter = ".shift };
poj

In reply to Re: Using CGI::Ajax for multiple form buttons/divs simultaneously by poj
in thread Using CGI::Ajax for multiple form buttons/divs simultaneously by Polyglot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.