Jerry Kassebaum wrote:
> Friends.
>
> I want to pop up an alert if a checkbox isn't checked.
>
> Below is the code I have so far.
>
> Notes:
> 1. The cgi page is actuatlly at
> http://www.biblescramble.com/Esther/scriptCheck.cgi
> 2. x.cgi doesn't exist. This doesn't get that far. I'm just working on the
> alert.
> 3. "if(1==1)" obviously is what needs to be changed.
>
> ###
> #!/usr/bin/perl
>
> use CGI qw/:standard/;
> use CGI::Carp qw(carpout fatalsToBrowser);
>
> $script=<<END;
> function valid8() {
> if (1==1) {
> alert("Not checked.");
> }
> }
> END
>
>
> print header('text/html'),
>
> start_html(-title=>"Check if check checked", -script=>$script),
>
> start_form(-name, "formA", -method, "post", -action, "x.cgi",
> -onSubmit=>"return valid8()"),"\n",
>
> h2("Check this"), p, checkbox(-name, "checker", value, "checker"), br,
>
> p,submit("Submit"),
>
> end_form,
>
> end_html;
> ###
#!perl --
use strict;
use warnings;
use CGI qw/:standard/;
use CGI::Carp qw(carpout fatalsToBrowser);
my $script = <<'END';
function valid8 () {
var f = document.forms["formA"];
var els = f.elements;
var ck = els["checker"].checked;
if (! ck) {
alert ("Not checked");
// I'm not sure how you keep the submit from going at this point
}
}
END
print header('text/html'),
start_html(-title => 'Check if check checked', -script => $script), "\n",
start_form(-name => 'formA', -method => 'post', -action => 'penv.pl',
-onSubmit => 'return valid8 ()'), "\n",
h2('Check this'), "\n", p, checkbox(-name => 'checker', value =>
'checked'),
p, "\n", br, submit('Submit'), "\n",
end_form, "\n",
end_html, "\n";
__END__
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs