Hello Monks!

Back again with another problem I'm stuck on.. I couldn't find my answer or know how to narrow down my search on google to find my answer so I'm asking here again.

So I've had some help with using ajax in a .cgi code which was what I needed. But the original code was an <input> type and I wanted it to be a drop down list.

The problem is that I do not know how to squeeze the commented out for into the html where the dropdown list would be.

Here's the code

my $cgi = new CGI; my $pjx = new CGI::Ajax( 'exported_func' => \&perl_func ); my $dirname = ''; opendir my($dh), $dirname or die "Couldn't open dir'$dirname':$!"; my @files = readdir $dh; my $files; closedir $dh; #for my $i ( 2 .. $#files ) { # print "<option value=\"$files[$i]\">$files[$i]</option>\n"; # }; sub perl_func { my $input = shift; my $output = $input . "was the input!"; return ($output); } print $pjx->build_html( $cgi, \&Show_HTML); sub Show_HTML { my $html = <<__EOI__; <!DOCTYPE html> <html> <head> <script type="text/javascript" src="\jquery.js"></scri +pt> <script type="text/javascript" src="script.js"></scrip +t> <script type="text/javascript" src="stats.js"></script +> <title> Graph </title> </head> <body> <form action=''> <select name="users" id="users" onChange="expo +rted_func( ['users'], ['files'] );"> </select> </form> <div id="files"></div> </body> </html> __EOI__ return $html;

Thanks in advance!


In reply to HTML/CGI for loop problem by Jabox

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.