in reply to Re^2: obtaining yyyy-mm-dd via a calendar object
in thread obtaining yyyy-mm-dd via a calendar object
Based on this, here's where i'm at. let's take something a bit more simple to work out my kinks between Perl and Javascript (using what was in CPAN).
a) it appears the javascipt must be put in-line with the Perl code as in the below code. I'd rather be able to keep the javascript separate if there is a way to do so...the major problem I see with this approach is the javascript source is printed out in it's entirety! It just clutters up the screen. So the first question, is how does one suppress the printout of the javascript?
b) second question, i want to reference the variable 'answer' inside the javascript and place it in the form textfield 'answer'
#! /usr/bin/perl -wT use CGI qw(:standard escapeHTML); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use strict; print header (), my $JSCRIPT=<<END; // Ask a silly question function riddle_me_this() { var r = prompt("What walks on four legs in the morning, " + "two legs in the afternoon, " + "and three legs in the evening?"); response(r); } // Get a silly answer function response(answer) { if (answer == "man") alert("Right you are!"); else alert("Wrong! Guess again."); } END print start_html(-title=>'The Riddle of the Sphinx', -script=>$JSCRIPT); print p ("Element names & values submitted in previous form:"); my @names = param (); # get list of parameter names if (!@names) { print p ("(no elements present)"); } else { my @item = (); foreach my $name (@names) { my @val = param ($name); $val[0] = "[" . join (", ", @val) . "]" if @val > 1; push (@item, escapeHTML ("$name: ($val[0])\n")); } print ul (li (\@item)); } print hr (); print start_form (-action => url ()), p ("Enter riddle answer:", textfield (-name =>"answer", -id=>'response +1' -type=>"text", -size=>"30"), button(-name=>'riddle_button', -valu +e=>'Ask A Riddle', -onClick=>"riddle_me_this(response1)")), br(), p ("Enter your name:", textfield (-name =>"name", -type=>"text", -size +=>"30")), br(), submit (-name => "Submit Button", -value => "Submit"), reset (-name => "Reset Button", -value => "Reset"), end_form (); print end_html (); exit (0);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: obtaining yyyy-mm-dd via a calendar object
by Asim (Hermit) on Jul 31, 2006 at 14:45 UTC | |
by gmacfadden (Sexton) on Aug 03, 2006 at 20:53 UTC | |
by Asim (Hermit) on Aug 03, 2006 at 21:41 UTC | |
by gmacfadden (Sexton) on Aug 04, 2006 at 00:19 UTC | |
by Asim (Hermit) on Aug 04, 2006 at 13:40 UTC | |
|