Code Comments
Programming Forum and web based access to our favorite programming groups.Hi all,
I am having a submit button and upon clicking it i am
asking the user for confimation [for this i have used javascript].
When the user selects yes i should be able to call another subroutine.
But i am going wrong somewhere. Here's the code for your reference.
Please help me to solve this. Thanks!
#!/usr/bin/perl -w
use strict;
use CGI;
&main();
exit(0);
sub main {
my $cmd = CGI::param('cmd');
&mainPage() if($cmd eq "");
&deletePage() if($cmd eq "true");
}
sub mainPage {
print "Content-type: text/html\n\n";
print "<title>Documents</title>\n";
print "<link href=style.css rel=stylesheet type=text/css>\n";
print <<HTML;
<head>
<script type='text/javascript'>
function change()
{
var confirm_delete = confirm("sure?");
if(confirm_delete == true)
window.location = window.location.protocol + '//'
+window.location.host + window.location.pathname + "?cmd=" +
confirm_delete;
else
{
alert("Delete action cancelled!");
window.location.reload();
}
}
</script>
</head>
HTML
print "<body>\n";
print <<HTML;
<form action=files.cgi method="POST">
<input type=hidden name=cmd value=delete>
<input type=hidden name=filedir value=up>
<input type=hidden name=filename value=down>
<input type=submit value=Delete onclick = change()>
</form>
HTML
}
sub deletePage {
print "File was deleted successfully!<br>";
}
Post Follow-up to this messageDeepan - M.Sc(SE) - 03MW06 wrote:
> I am having a submit button and upon clicking it i am
> asking the user for confimation [for this i have used javascript].
> When the user selects yes i should be able to call another subroutine.
> But i am going wrong somewhere.
<snip>
> print <<HTML;
> <form action=files.cgi method="POST">
> <input type=hidden name=cmd value=delete>
Maybe you meant that to be
<input type=hidden name=cmd value=true>
> sub deletePage {
>
You need a content-type header here.
print CGI::header();
> print "File was deleted successfully!<br>";
>
> }
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.