in reply to [Re]confirm box

One thing I notice in your Javascript where the condition is false you need to return false otherwise the form will go ahead and submit anyway.
print qq|if (answer == false ){ \n|; print qq|document.write('You chose to Cancel. Closed window.');\n|; print qq|return false;\n|;
Also, I think you need the Javascript function to be called on the form like this:
print qq|<form name="form1" action="disable.cgi" method="post" onsubmi +t="return CheckForm_onclick()">|
Note also the use of the quote operator qq|| so you don't need to escape the quote marks etc.

Replies are listed 'Best First'.
Re^2: [Re]confirm box
by kbee (Initiate) on Dec 23, 2014 at 13:55 UTC

    Thanks for the quick response. I'll try out the feedback today.

Re^2: [Re]confirm box
by Anonymous Monk on Dec 24, 2014 at 06:40 UTC
    Might be cleaner to put all the javascript code inside __DATA__ section, then just open it, and loop through readline/print to display on stdout?

      Might be cleaner

      Not really :) The ultimate in clean is using well named subroutines that seperate code/logic from templates ... its cgi101

        Okay sure, I just said that because it's strange to see all those print() and \n to output strings with embeddeded code. It just doesn't look nice visually (and probably not fun to debug if javascript gets big or halfway complicated). One thing I don't understand in the example you linked though... Why did he use this double negation construction in the ValidLogin() sub:

        return !!1 if $user eq $pass; return !!0;

        It seems redundant? Actually why even use any ! operators at all and just return the literal code you intend. I can sort of see doing this for exit() to the shell, because the shell exit codes are backwards from Perl. An exit code 0 means success, whereas inside Perl program boolean 0 is false.