troubleshooting Question

Open new window after form submit

Avatar of tel2
tel2Flag for New Zealand asked on
JavaScriptPerlWeb DevelopmentHTML
35 Comments2 Solutions195 ViewsLast Modified:
Hi Web Dev Experts,

I'm not sure how Perlish this will work out to be, but I’ve got an existing Perl CGI application which contains a form, which when submitted with the appropriate values, redisplays that same form (as per the form action).  That part works fine, but I’d like to make it so the submit opens a separate window (browser tab) at the same time, and displays a table in it.  The source of the HTML for that table is in a variable (say $table), not in a file.

The user would then either copy data from that table on the new window to the clipboard, or print the webpage, and when finished the user would close the window leaving them with the original window (which contains the form) only.

(One reason I want a new window is, it has to contain the table only, because I don't want any thing else like navigation controls being included in any printout, and I don't want the user to have to click the browser's back button to get back to the main window.)
I know I could write the HTML in $table out to a file, then display a link to that file (e.g. <a href="table.txt" target="_blank">Click for printable table</a>) on the main window after the submit, which the user could then click, but that’s an extra step for the user which I definitely want to avoid, which is why I’m asking for help.
I’d also prefer not to write the table to a file, mainly because then I have to somehow delete it after it’s been used, which is just more work, but I’m flexible on this.
Any suggestions on how to achieve the above, please?

I'm not wanting any jQuery solutions, but I might be willing to tolerate a bit (or even a byte) of plain JavaScript if required.
I'm using Perl's CGI module, so maybe it has something which could help.

I've also posted this question here:

Join our community to see this answer!
Unlock 2 Answers and 35 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 35 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros