Home  |  Linux  | Mysql  | PHP  | XML
From:Deepan - M.Sc\(SE\) - 03MW06 Date:Mon Mar 17 23:16:11 2008
Subject:DeletePage
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>";

}

Navigate in group perl.beginners.cgi at sever nntp.perl.org
Previous Next




  
© No Copyright
You are free to use Anything
Site Maintained by PHP Developer
Powered By PHP Consultants