okay, i'm making a noble attempt to develop my web application in pure perl, even though i need ajax functionality. i don't like or understand javascript. yuck. thus, cgi:ajax, which works, though it stifles and obscures any and all error messages. this script works great on IE - it allows you to connect to the dB, select the latin binomial of an animal, then see some info from the dB about that animal (without reloading the page). with FF, the second bit of ajax, where you select a binomial, works the first time, but won't work a second time. btw, cgi:ajax hates lexical data, so i gave up on that for now. if there's no one to help with this, or if it's just outdated technology, how would i go about a more modern solution?

thanks, this is for an ecology lab, so gaia loves you back!

#! /usr/bin/perl -w #use strict; use CGI::Ajax; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use DBI; $cgi = new CGI; my $Show_Form = sub { my $dBopts=["primates", "rodents", "ungulates", "carnivores"]; my @html =($cgi->header(-type=>"text/javascript" -src=>"bindin +g.js"), $cgi->start_html(-title=>'GDET Intro Page'), $cgi->center($cgi->h3("GMPD Data Entry Tool Introducti +on")),$cgi->p, $cgi->h3("Please select a database"), $cgi->startform(-name=>'Select1', -method=>'POST'), "User Name :", $cgi->textfield(-name=>'user', -id=>"user"), "Password :", $cgi->password_field(-name=>'password', -id=>"password +"), "Database :", $cgi->popup_menu(-id=>"Database", -name=>"Database", - +value=>$dBopts, -width=>'1'), ##First AJAX trick here, this works $cgi->button(-name=>"SelectdB", -value=>"SelectdB", -o +nClick=>"connectdB( ['Database', 'user', 'password'], ['div3', 'extre +f', 'extloc', 'exthost', 'extpara']); return true;"),$cgi->p); $html=join("\n", @html); my @boxhtml=($cgi->h4("Connection status:"), $cgi->div({-id=>"div3"}), $cgi->end_div(-id=>"div3")); my $boxhtml=join("\n", @boxhtml); $html .= $boxhtml; my $loccellhtml=join("\n", ($cgi->div({-id=>'extloc', -style=> +'width: 350px; height: 20px; overflow: auto'}), $cgi->end_div({-id=>'extloc'} +))); my $refcellhtml=join("\n", ($cgi->div({-id=>'extref', -style=> +'width: 350px; height: 20px; overflow: auto'}), $cgi->end_div({-id=>'extref'} +))); my $hostcellhtml=join("\n", ($cgi->div({-id=>'exthost', -style +=>'width: 350px; height: 20px; overflow: auto'}), $cgi->end_div({-id=>'extref'} +))); my $paracellhtml=join("\n", ($cgi->div({-id=>'extpara', -style +=>'width: 350px; height: 20px; overflow: auto'}), $cgi->end_div({-id=>'extref'} +))); my @formhtml=($cgi->startform(-name=>'Select1', -method=>'POST +'), $cgi->table({-border=>"2"}, $cgi->Tr({-align=>"LEFT",-valign=>"Center"}, $cgi->td([$cgi->h4("Host Reported Name +")]), $cgi->td([$cgi->center($cgi->submit(-n +ame=>'NewHostTax', -value=>"New Host\n Taxonomy", -onClick=>"document +.fork1.action='GDETNewLoc.cgi';"))], -colspan=>1), $cgi->td([$hostcellhtml], -colspan=>2 +, -align=>"center")), $cgi->Tr({-align=>"LEFT",-valign=>"Center"}, $cgi->td([$cgi->h4("Parasite Reported + Name")]), $cgi->td([$cgi->center($cgi->submit(- +name=>'NewParaTax', -value=>"New Parasite\n Taxonomy", -onClick=>"doc +ument.fork1.action='GDETNewRef.cgi';"))], -colspan=>1), $cgi->td([$paracellhtml], -colspan=>2 +, -align=>"center")), $cgi->Tr({-align=>"LEFT",-valign=>"Center"}, $cgi->td([$cgi->h4("Location Name")]) +, $cgi->td([$cgi->center($cgi->submit(- +name=>'NewLocation', -value=>'New Location', -onClick=>"document.fork +1.action='GDETNewLoc.cgi';"))], -colspan=>1), $cgi->td([$loccellhtml], -colspan=>2, + -align=>"center")), $cgi->Tr({-align=>"LEFT",-valign=>"Center"}, $cgi->td([$cgi->h4("Citation")]), $cgi->td([$cgi->center($cgi->submit(- +name=>'NewReference', -value=>'New Reference', -onClick=>"document.fo +rk1.action='GDETNewRef.cgi';"))], -colspan=>1), $cgi->td([$refcellhtml], -colspan=>2, + -align=>"center"))), $cgi->submit(-name=>'GDETNewMAIN.cgi', -value=>"Enter +MAIN\n record", -onClick=>"document.cookie = 'gotopage=GDETNewMAIN.cg +i';document.Select1.action='storecookies.cgi'; return true;"), $cgi->endform); my $hostdatahtml=join("\n", ($cgi->div({-id=>'hostdata +', -style=>'width: 350px; height: 100px;'}), $cgi->end_div({-id=>'hos +tdata'}))); my $paradatahtml=join("\n", ($cgi->div({-id=>'paradata +', -style=>'width: 350px; height: 20px; overflow: auto'}), $cgi->end_ +div({-id=>'paradata'}))); my $locdatahtml=join("\n", ($cgi->div({-id=>'locdata', -style= +>'width: 350px; height: 20px; overflow: auto'}), $cgi->end_div({-id= +>'locdata'}))); my $refdatahtml=join("\n", ($cgi->div({-id=>'refdata', -style= +>'width: 350px; height: 20px; overflow: auto'}), $cgi->end_div({-id= +>'refdata'}))); my @displaytable=($cgi->table({-border=>"2"}, $cgi->Tr({-align=>"LEFT",-valign=>"Center"}, $cgi->td([$hostdatahtml], -colspan=>2, -align= +>"center")), $cgi->Tr({-align=>"LEFT",-valign=>"Center"}, $cgi->td([$paradatahtml], -colspan=>2, -align= +>"center")), $cgi->Tr({-align=>"LEFT",-valign=>"Center"}, $cgi->td([$locdatahtml], -colspan=>2, -align=> +"center")), $cgi->Tr({-align=>"LEFT",-valign=>"Center"}, $cgi->td([$refdatahtml], -colspan=>2, -align=> +"center")))); my $metatable=$cgi->table({-border=>'0'}, $cgi->Tr({-align=>"LEFT",-valign=>"Top"}, $cgi->td([@formhtml]), $cgi->td([@displaytable]))); #my $formhtml=join("\n", @formhtml); #$html .= $formhtml; $html .= $metatable; my $extradiv=join("\n", ($cgi->div({-id=>'extra', -style=>'wid +th: 350px; height: 100px; overflow: auto;'}), $cgi->end_div({-id=>'e +xtra'}))); $html .= $extradiv; $html .= $cgi->end_html; return ($html); }; my $showhostdata=sub { $hostreptname=shift; #$hostreptname=$cgi->param("Hosts"); $dB=shift; $user=shift; $password=shift; $dBprefix="Ung" if($dB eq "ungulates"); $dBprefix="Sqrl" if($dB eq "rodents"); $dBprefix="Carn" if($dB eq "carnivores"); $dBprefix="Prim" if($dB eq "primates"); $tablename="$dBprefix" . "HostTax"; $connectstring=join(":", "DBI", "mysql", $dB, "128.192.18.43:3 +306"); %dBattr = ( PrintError => 0, RaiseError => 0 ); $dbh = DBI->connect($connectstring, $user, $password, \%dBattr +) or die; my $qtdhostreptname=$dbh->quote($hostreptname); my $query="SELECT HostCorrectedName FROM $tablename WHERE Host +ReportedName=$qtdhostreptname"; $sth=$dbh->prepare($query); $sth->execute; $hostcortname=@{$sth->fetch}[0]; my $qtdhostcortname=$dbh->quote($hostcortname); my $query2="SELECT HostAuthority, TaxOrder, Family, Notes FROM + $tablename WHERE HostReportedName=$qtdhostcortname AND HostCorrected +Name=$qtdhostcortname"; $sth=$dbh->prepare($query2); $sth->execute; @hostcortdata=@{$sth->fetch}; @listdata=(("Corrected Name:" . "\t$hostcortname"), ("Host Authority: " . "\t$hostcortdata[0]"), ("Host Order:" . "\t$hostcortdata[1]"), ("Host Family:" . "\t$hostcortdata[2]"), ("Notes:" . "\t$hostcortdata[3]")); $dbh->disconnect; return($cgi->scrolling_list("showhostdata", \@listdata), $host +reptname); }; my $connectdB=sub { my $dB=shift; my $user=shift; my $password=shift; my %tables = ("References" => Citation, "Locations" => LocationName, "ParasiteTax" => ParasiteReportedName, "HostTax" => HostReportedName ); # my $dBprefix; $dBprefix="Ung" if($dB eq "ungulates"); $dBprefix="Sqrl" if($dB eq "rodents"); $dBprefix="Carn" if($dB eq "carnivores"); $dBprefix="Prim" if($dB eq "primates"); $connectstring=join(":", "DBI", "mysql", $dB, "128.192.18.43:3 +306"); %dBattr = ( PrintError => 0, RaiseError => 0 ); $dbh = DBI->connect($connectstring, $user, $password, \%dBattr +) or die; foreach $table (keys %tables) { $tablename="$dBprefix" . "$table"; $searchstr=$tables{$table}; $query="SELECT DISTINCT $searchstr FROM $tablename"; #$html=$cgi->h5($query); $sth=$dbh->prepare($query) or $html=$cgi->h4($dbh->err +str()); $sth->execute() or $html=$cgi->h4($sth->errstr()); while(@row = $sth->fetchrow_array) { for $i (0..($sth->{NUM_OF_FIELDS}-1)) { push(@returnrows, $row[$i]); } } unshift(@returnrows, ""); $$table=[@returnrows]; undef @returnrows; } $html=$cgi->h6("connected to $dB as $user"); $extantrefs=$cgi->popup_menu(-name=>"References", -value=>$Ref +erences, -width=>"200"); $extantlocs=$cgi->popup_menu(-name=>"Locations", -value=>$Loca +tions, -width=>"200"); ##Second AJAX trick here, works in IE $extanthosts=$cgi->popup_menu(-name=>"Hosts", -value=>$HostTax +, id=>"Hosts", -onChange=>"showhostdata(['Hosts', 'Database', 'user', + 'password'], ['hostdata', 'extra']); return true;"), $extantparas=$cgi->popup_menu(-name=>"Parasites", -value=>$Par +asiteTax, -width=>"200"); #print $cgi->redirect(-location=>"GDETNewMAIN.cgi"); return($html, $extantrefs, $extantlocs, $extanthosts, $extantp +aras); }; my $pjx = CGI::Ajax->new(connectdB => $connectdB, showhostdata => $showhostdata); $pjx->JSDEBUG(1); $pjx->DEBUG(1); print $pjx->build_html($cgi,$Show_Form);

In reply to cgi:ajax firefox vs. ie, popup_menu won't update by tantric

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.