Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

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>";

}


Report this thread to moderator Post Follow-up to this message
Old Post
Deepan - M.Sc - 03MW06
03-18-08 12:56 PM


Re: DeletePage
Deepan - 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

Report this thread to moderator Post Follow-up to this message
Old Post
Gunnar Hjalmarsson
03-18-08 11:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL CGI Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 02:09 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.