I am in an unique 'perl' situation in trying to embed a reconfirm box into an existing perl/cgi script, and let the perl script continue processing through its code based on the yes/no response of the user. To further describe my situation, the user currently launches an operational webpage and selects an app service and an actioneither activate, de-activate or check status and clicks submit. A confirm box shows up to accept the yes/no response from the user. A yes response results in the servicename and action passed onto the perl/cgi script which goes ahead in carrying out the selected action while displaying the results in a separate window with appropriate header and footer information. I needed to embed a confirm box again into the perl code if the action was 'de-activate' and have perl hold its further processing until the user responds back with a yes again. So far after googling through web postings and using perl/javascript snippet examples, the perl/cgi script does throw up the second confirm box if the action is de-activate, but it continues onward irrespective of a response from the box or not. I have attached sections of the code below and appreciate your expert advice from you perl monks. Though I am familiar with perl programming, integrating the second confirm box has been a challenge. Thanks for reading my post.

#!/usr/bin/perl -w # use CGI; use CGI::Carp qw (fatalsToBrowser); use Cwd; use lib getcwd . '/lib'; use COI::INIFile; use COI::Logger; use File::Basename; use COI::Commands; use Sys::Hostname; use strict; ...... ...... my $q = CGI->new; print $q->header('text/html'); #print $q->Dump(%ENV); ### get values from html form my $username = $q->param("username"); my $action = $q->param("option_1") ; my $service = $q->param("option_2") ; print "</left><pre>\n"; &print_header; if ( $action eq 'Status') { my $wait_for_user_response = "yes"; if(defined($q->param("userresponse"))) { if($q->param("userresponse") eq "yes") { print "go ahead \n"; } else { print "don't go ahead \n"; } } print "<html>\n"; print "<head>\n"; print "<LANGUAGE=Javascript>\n"; print "<script>\n"; print "function CheckForm_onclick()\n"; print "{\n"; print "var myForm = document.form1;\n"; print "var message = \"\";\n"; print "message = \"Confirm if you need to disable $ser +vice. Choose OK to go ahead and Cancel to abort.\";\n"; print "var answer = confirm(message);\n"; print "if (answer == false ){ \n"; print "document.write(\'You chose to Cancel. Closed wi +ndow.\');\n"; print "}\n"; print "else {\n"; print "document.getElementById(\"userresponse\").value + = \"Yes\";\n"; print "document.form.submit();\n"; print "}\n"; print "}\n"; print "</SCRIPT>\n"; &reconfirm_form; } print "\n Going ahead made it\n"; &footer(); sub reconfirm_form { print "<title>$tool_desc</title>\n"; print "</head>\n"; print "<body onload=\"return (CheckForm_onclick())\">\n"; print "<FORM action=\"disable.cgi\" method=\"post\">\n"; print "<input type=\"hidden\" name=\"userresponse\" >\n"; print "</form>\n"; print "</body>\n"; print "</html>\n"; }

In reply to [Re]confirm box by kbee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.