Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^4: Perl CGI redirect

by poj (Prior)
on Apr 17, 2013 at 15:53 UTC ( #1029172=note: print w/replies, xml ) Need Help??

in reply to Re^3: Perl CGI redirect
in thread Perl CGI redirect

Not sure about multiple servers but to open a new page you can do it with some javascript. I have added the javascript to a new clickme button as an example.
#!/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"> &nbsp; </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 = '' .'&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) { }; } 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

    Thanks for the response. However this adds the client to the end of the URL instead of adding it to place listed as XXXX. I tried to specift $ta, however it fails with the below error my $URL = "$FM&toDateStr=$TM"; Wed Apr 17 15:43:03 2013 n.cgi: Global symbol "$ta" requires explicit package name at ./n.cgi line 42. Wed Apr 17 15:43:03 2013 n.cgi: Execution of ./n.cgi aborted due to compilation errors.

      The parameter order should not normally matter but if it does just revise the javascript as follows
      my $JSCRIPT=<<EOF; function clickme(){ var URL = '' + '&operation=BackupHistorySearch' + '&subOperation=GetReport' + '&clientName=' + document.getElementById("ta").value + '&fromDateStr=$FM&toDateStr=$TM' // comment out if or remove when working OK if (confirm(URL)==true) { }; } EOF

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1029172]
[RonW]: Is there an English language version of the site?
[LanX]: but Afaik Perl is on average about 10-20 times slower than C
[LanX]: no
[LanX]: but I could ask Herbert to elaborate
[1nickt]: performance_benchm arks.html
[RonW]: 1nickt: Thanks. Looking at that

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2017-05-22 20:22 GMT
Find Nodes?
    Voting Booth?