monkfan has asked for the wisdom of the Perl Monks concerning the following question:
I have a perfectly functioning stand alone html page with that Javascript in it. The content of that html is this:#!/usr/bin/perl -w use strict; use diagnostics; use Data::Dumper; use CGI qw/:standard :html3/; use CGI::Carp qw( fatalsToBrowser ); my $JSCRIPT=<<EOF; var twofastest; var checkboxes=[]; function initVars(){ if ( twofastest ) return; twofastest = document.getElementById('2 Fastest'); var cb = document.getElementsByName('progname'); var b = 0; for (var a=0; a<cb.length; a++ ){ if ( cb[a] != twofastest ){ checkboxes[b] = cb[a]; b++; } } } function checkBoxClick(){ initVars(); var anyboxchecked = false; for (var a=0; a<checkboxes.length; a++ ){ if ( checkboxes[a].checked ) anyboxchecked = true; } twofastest.disabled = anyboxchecked; } function twofastestClick(){ initVars(); for (var a=0; a<checkboxes.length; a++ ){ if ( twofastest.checked ) checkboxes[a].checked = false; checkboxes[a].disabled = twofastest.checked; } } EOF ; print header, start_html( -title => "Some Title", -script=> $JSCRIPT ); # some portions of code sub generate_form { print start_multipart_form(), strong('Basic Programs To Choose: '), br checkbox_group( -name => 'progname', -values => [ '2 Fastest', 'MEME', 'MITRA', 'SPACE', ], -rows => '2', -columns => '6', -defaults => [ '2 Fastest' ], # modified as advised by ikegami, # but still not functioning -onClick=>"checkBoxClick()", ), p, } # the rest of codes
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:/ +/www.w3.org/TR/html4/loose.dtd"> <html> <head> <title></title> <meta name="GENERATOR" content="VIM"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script language="JavaScript"> var twofastest; var checkboxes=[]; function initVars(){ if ( twofastest ) return; twofastest = document.getElementById('twofastest'); var cb = document.getElementsByName('progname'); var b = 0; for (var a=0; a<cb.length; a++ ){ if ( cb[a] != twofastest ){ checkboxes[b] = cb[a]; b++; } } } function checkBoxClick(){ initVars(); var anyboxchecked = false; for (var a=0; a<checkboxes.length; a++ ){ if ( checkboxes[a].checked ) anyboxchecked = true; } twofastest.disabled = anyboxchecked; } function twofastestClick(){ initVars(); for (var a=0; a<checkboxes.length; a++ ){ if ( twofastest.checked ) checkboxes[a].checked = false; checkboxes[a].disabled = twofastest.checked; } } </script> </head> <body> <form action=""> <input type="checkbox" name="progname" value="2fastest" id="twofas +test" onClick="twofastestClick()">2 Fastest<br/> <input type="checkbox" name="progname" value="mitra" onClick="checkBoxClick()" />MITRA <br/> <input type="checkbox" name="progname" value="space" onClick="checkBoxClick()" />SPACE <br/> <input type="checkbox" name="progname" value="meme" onClick="checkBoxClick()" />MEME <br/> </form> </body> </html>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Howto Include JavaScript to CGI.pm Script
by ikegami (Patriarch) on Aug 28, 2007 at 03:09 UTC | |
|
Re: Howto Include JavaScript to CGI.pm Script
by ikegami (Patriarch) on Aug 28, 2007 at 02:25 UTC | |
|
Re: Howto Include JavaScript to CGI.pm Script
by atemon (Chaplain) on Aug 28, 2007 at 03:47 UTC | |
|
Re: Howto Include JavaScript to CGI.pm Script
by misc (Friar) on Aug 28, 2007 at 10:09 UTC | |
|
Re: Howto Include JavaScript to CGI.pm Script
by ph0enix (Friar) on Aug 28, 2007 at 14:29 UTC | |
by Anonymous Monk on Jun 15, 2009 at 11:40 UTC | |
by Anonymous Monk on Feb 25, 2011 at 06:22 UTC |