in reply to Re^3: Perl CGI redirect
in thread Perl CGI redirect
poj#!/usr/bin/perl # n.cgi use strict; use CGI qw( :standard ); use CGI::Carp qw( fatalsToBrowser ); use POSIX qw(strftime); my $today = time; my $yesterday = $today - 60 * 168 * 60; my $FM = strftime "%m-%d-%Y", ( localtime($yesterday) ); my $TM = strftime '%m-%d-%Y', localtime; # page layout my $page =<< "EndOfText"; <h2>Add Logical:</h2> <form name="form" method="post" action="n.cgi"> <table> <tr> <td align="right"><strong>Logical:</strong></td> <td> <textarea id="ta" name="server" rows="1" cols="30" wrap="soft"></te +xtarea> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td> <button type="button" onClick="javascript:clickme()">Click Me</ +button></td> <td> <input type="submit" name="action" value="Search" /> </td> </tr> </table> </form> EndOfText # construct URL my $URL = 'http://a.com:8080/bms/healthMonitor.do?method=redirect' .'&operation=BackupHistorySearch' .'&subOperation=GetReport' ."&fromDateStr=$FM&toDateStr=$TM"; # javascript my $JSCRIPT=<<EOF; function clickme(){ var URL = \'$URL\' + '&clientName=' + document.getElementById("ta").value // comment out if or remove when working OK if (confirm(URL)==true) { window.open(URL) }; } EOF # get parameters my $q = CGI->new; my $action = $q->param('action'); my $server = $q->param('server'); # add server $URL .= "&clientName=$server"; # redirect if required if ($action eq 'Search'){ # remove hash to redirect print $q->redirect($URL); } else { print $q->header, $q->start_html( -title => "Some Title", -script=> $JSCRIPT), $page, $q->end_html; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Perl CGI redirect
by Anonymous Monk on Apr 17, 2013 at 19:59 UTC | |
by poj (Abbot) on Apr 17, 2013 at 20:31 UTC |