Pop up confirmation box / perl cgi


 
Thread Tools Search this Thread
Top Forums Web Development Pop up confirmation box / perl cgi
# 1  
Old 07-06-2014
Pop up confirmation box / perl cgi

Hi,

I need to add confirmation pop up msg box before deleting the record from database, I have added following snippets to my code but its not working for me, your help will be much appreciated :

Code:
print header;
print <<EOF;
<script type="text/javascript">
function confirmOk() {
return window.confirm("Confirm deletion?");
}
</script>
EOF

And

Code:
# If the form was properly submitted, save the data
if ($input{"go"} eq "DELETE") {
 
print button(-name=>'Delete',
-value=>'DO you really want to delete it ?',
-onClick=>"return confirmOk()");
 
$query = "DELETE ....

Many thanks
Terry

---------- Post updated at 05:26 AM ---------- Previous update was at 03:57 AM ----------

Following is the complete script :

Code:
#!/usr/local/bin/perl
use CGI;
use DBI;
# Make up a pulldown menu of all known patients
$db_handle = DBI -> connect("DBI:Pg:dbname=northwind;
                                    host=localhost",
                                    "postgres",
                                    "postgres",
                                    {'RaiseError' => 1});
$query = "SELECT 
             \"EmployeeID\" AS empid, 
             \"FirstName\"::text || ' ' ||\"LastName\"::text AS name 
          FROM 
             \"Employees\"";
$db_handle->do("SET search_path to northwind") or die;
$qh = $db_handle->prepare($query);
$qh->execute;
while (@row = $qh->fetchrow) {
        $hh .= "<option value=$row[0]>$row[1]</option>\n";
        }
# Send out the header and form
print "content-type: text/html\n\n";
print <<"HEADER";
<html>
<head>
<title>Delete an employee record</title>
<body bgcolor=pink text=#3300CC border=2 bordercolor=pink >
<h1 style="color:3300CC;">Delete an employee</h1>
    <style type="text/css">
    .container {
        width: 500px;
        clear: both;
    }
    .container input {
        width: 100%;
        clear: both;
    }
    </style>
</head>
<div class="container">
<form method=POST>
Select Employee name to delete :<select name=empid>$hh</select><br>
<input type=submit name=go value=DELETE>
</div>
</form><hr>
HEADER
print header;
print <<EOF;
<script type="text/javascript">
function confirmOk() {
   return window.confirm("Confirm deletion?");
}
</script>
EOF 
 
# Read information from the form
read(STDIN,$buffer,$ENV{CONTENT_LENGTH});
@pairs = split(/&/,$buffer);
foreach (@pairs) {
        ($n,$v) = split(/=/);
        $v =~ tr/+/ / ;
        $v =~ s/%(..)/pack("C",hex($1))/ge;
        $input{$n} = $v;
        }
# If the form was properly submitted, save the data
if ($input{"go"} eq "DELETE") {
print button(-name=>'Delete',
                         -value=>'DO you really want to delete it ?',
                         -onClick=>"return confirmOk()");
$query = "DELETE
          FROM 
              \"Employees\" 
          WHERE 
              \"EmployeeID\"="." \'$input{empid}\'";
$db_handle -> do($query);
$action = "Record saved - $query";
 
# If the form has not been submitted, ask for data
}  else {
$action = "Please complete form";
}
# Standard links to the rest of the application
print <<"FOOTER";
<b>$action</b>
<hr>
Jump to - <a href=http://localhost/perlproj/cgi-bin/emp2.pl>View Employees Listing</a><br>
Jump to - <a href=http://localhost/perlproj/cgi-bin/addemp.pl>Add an Employee</a><br>
Jump to - <a href=http://localhost/perlproj/cgi-bin/updatephoto.pl>Add or update Employee Photo</a><br>
<hr>
Edited by Terry on July, 06 2014.
</body></html>
FOOTER

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to shutdown Linux box with user confirmation?

Hi Guru's Am looking for linux reboot command which get executed after user confirmation .Can someone please help me with this.:confused::confused::confused: (6 Replies)
Discussion started by: kapil514
6 Replies

2. OS X (Apple)

Perl CGI

I am trying to get my MacBook Pro with 10.8 Mt Lion set up to run Perl CGI scripts. Having a problem. I can start Apache Web Server with no problems. Why do I put the static and dynamic scripts? I which directory? I have looked at this article:... (3 Replies)
Discussion started by: djehresmann
3 Replies

3. Shell Programming and Scripting

CGI Perl : while loop in CGI perl

Hi Team, I am trying to connect to database(succeeded ) and print the records on the browser using while loop. But the elements of array are not displayed instead while loop is displayed directly. Instead of the below I can embed html statements in print but I am looking for the below style as I... (1 Reply)
Discussion started by: scriptscript
1 Replies

4. Shell Programming and Scripting

Perl CGI : unable to download the excel sheet from perl cgi page

Hi All, I have written an cgi perl script that displays an image(Excel image) and when clicked on that Image I need to download a excel sheet. I made sure that excel sheet exists in the folder with the given name but still I am not able to download the sheet. print "<center><table... (2 Replies)
Discussion started by: scriptscript
2 Replies

5. Shell Programming and Scripting

Perl cgi pages out of cgi-bin folder in WINDOWS

Hi team, I have a typical problem with cgi pages in apache webserver in WINDOWS I am able to execute(display) the pages that are saved in cgi-bin folder. But I am not able to execute the pages stored in htdocs or other folder other than cgi-bin folder. Could anyone please let me know how... (1 Reply)
Discussion started by: scriptscript
1 Replies

6. Homework & Coursework Questions

Need help with a Perl Script using Pop, Shift, & Push

Hello everyone, I am new to Perl and I am having some issues getting a script to work. I have to create a script that uses an array of 52 cards, "shuffles" the cards (using loops with the pop, shift, and push commands), and prints out the top five. This is not a randomizing of the array just a... (2 Replies)
Discussion started by: Hax0rc1ph3r
2 Replies

7. Shell Programming and Scripting

CGI in Perl

Hi, Am unfamiliar with using CGI modules in Perl. Though i checked in few sites about CGI , i dint get a clear idea. Can anyone please explain me the purpose of these statements, it ll be very helpful to me #!/usr/bin/perl use CGI qw/:standard/; use Storable; use Data::Dumper; my... (1 Reply)
Discussion started by: irudayaraj
1 Replies

8. Web Development

problem with exporting vairable from one perl cgi to another perl cgi script while redirecting.

Can anyone tell me how to export a variable from one perl CGI script to another perl cgi script when using a redirect. Upon running the login.pl the user is prompted to enter user name and password. Upon entering the correct credentials (admin/admin) the user is redirected to welcome page. My... (3 Replies)
Discussion started by: Arun_Linux
3 Replies

9. Shell Programming and Scripting

Pop up dialog box on remote computers

I need to send out messages to over 100 clients in my sector. I want it to pop up a dialog box letting them know to save work and log out. I have the reboot script created just need the warning please. Thanks (35 Replies)
Discussion started by: deaconf19
35 Replies

10. Web Development

Pop up Confirmation Box

Hi, I was writing a simple web application using Perl -CGI. When users try to do some operations, I wanted like a pop-up confirmation box. Is this possible with Perl-CGI? Thanks in advance. Regards, garric (6 Replies)
Discussion started by: garric
6 Replies
Login or Register to Ask a Question