Hi Monks, I need to add a pop up confirmation box before deleting a record from database like "Yes/No" or "OK/Cancel". I found a thread here on perlmonk which is complicated for me as I am a very new in perl at http://www.perlmonks.org/?node_id=125561 If someone can help me do that will be a huge favor. Here is my script :
#!/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 # 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") { $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 Emplo +yees Listing</a><br> Jump to - <a href=http://localhost/perlproj/cgi-bin/addemp.pl>Add an E +mployee</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
Many tanks Terry

In reply to Adding a pop up confirmation box by terrykhatri

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.