Dancer-Plugin-FakeCGI

 view release on metacpan or  search on metacpan

examples/cgi-bin/CGI_pm_javascript.pl  view on Meta::CPAN

	   alert("Please enter date in format MMM DD, YY");
	   element.focus();
	   element.select();
       }
       return date;
   }

   // Compliments, compliments
    function doPraise(element) {
	if (element.checked) {
	    self.status=element.value + " is an excellent choice!";
	    return true;
	} else {
	    return false;
	}
    }

    function checkColor(element) {
	var color = element.options[element.selectedIndex].text;
	if (color == "blonde") {
	    if (confirm("Is it true that blondes have more fun?"))
		alert("Darn.  That leaves me out.");
	} else
	    alert(color + " is a fine choice!");
    }
EOF

# here's where the execution begins
print header;
print start_html(-title => 'Personal Profile', -script => $JSCRIPT);

print h1("Big Brother Wants to Know All About You"),
  strong("Note: "), "This page uses JavaScript and requires ",
  "Netscape 2.0 or higher to do anything special.";

&print_prompt();
print hr;
&print_response() if param;
print end_html;

sub print_prompt {
    print start_form(
        -name     => 'form1',
        -onSubmit => "return validateForm()"
      ),
      "\n";
    print "Birthdate (e.g. Jan 3, 1972): ",
      textfield(
        -name   => 'birthdate',
        -onBlur => "validateDate(this)"
      ),
      "<p>\n";
    print "Sex: ",
      radio_group(
        -name    => 'gender',
        -value   => [qw/male female/],
        -onClick => "doPraise(this)"
      ),
      "<p>\n";
    print "Hair color: ",
      popup_menu(
        -name     => 'color',
        -value    => [qw/brunette blonde red gray/],
        -default  => 'red',
        -onChange => "checkColor(this)"
      ),
      "<p>\n";
    print hidden(-name => 'age', -value => 0);
    print submit();
    print end_form;
}

sub print_response {
    import_names('Q');
    print h2("Your profile"),
      "You claim to be a ", b($Q::age), " year old ", b($Q::color, $Q::gender),
      ".",
      "You should be ashamed of yourself for lying so ",
      "blatantly to big brother!",
      hr;
}



( run in 1.023 second using v1.01-cache-2.11-cpan-364913b4093 )