3 # ajaxCheckbox.pl - a script to test Ajax functionality
10 # --- database authenication
11 my $dbh = do 'db.inc';
13 my $query = q{ SELECT project.project_id, project.name, project.phase, prio.prio,
14 HEX((255 - prio.prio)) AS hex, begun, tags
15 FROM project JOIN prio
16 ON (project.project_id = prio.project_id)
18 ORDER BY prio.prio DESC LIMIT 3};
20 my $sth = $dbh->prepare($query);
22 my $result = $dbh->selectall_arrayref($sth);
25 my $pjx = new CGI::Ajax( 'toStruck' => \&perl_func );
26 print $pjx->build_html( $cgi, \&Show_HTML);
30 use CGI qw/:standard/;
34 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
35 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
36 <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
38 <title>This is the lastest source version</title>
39 <link rel="stylesheet" type="text/css" href="/css/carrot.css" />
40 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
42 <h2>Carrot Queue</h2><a href="/cgi-bin/source_carrot/index.cgi">Priority List</a><b> | </b>
43 <a href="/cgi-bin/source_carrot/add.cgi">Add a listing</a><b> | </b><div class="content" /><h4>Project listing</h4>
46 foreach my $row (@$result) {
47 $html .= "<input type=\"checkbox\" name=name" . @$row[0] . " id=val" . @$row[0] . " value=\"ON\" onClick=\"toStruck( ['val@$row[0]'], ['div@$row[0]'] );\">";
48 $html .= "<div id=\"div@$row[0]\" style=\"display: inline;\"><!-- This gets entirely replaced -->" . @$row[1] . "</span></div><br>";
51 # you can append stuff to the HTML this way
52 $html .= "</body></html>";
60 # if onClick the change the style
62 $input="<span style=\"text-decoration: line-through; display: inline;\">";
64 $input ="<span style=\"text-decoration: none; display: inline;\">";