Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

(OT) To open a form in a new window

by Anonymous Monk
on Jan 04, 2004 at 12:41 UTC ( #318654=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This is not a specific Perl problem but it relates, so please bare with me. How do I set a form button or form action to open in a new pre-sized/scrollbarred window?

I can set the target of the form to target"blank" and that works fine, it opens in a new window and everything runs beautifully. But that doesn't allow me to change the window size or anything else. Someone suggested <input type=button value="Go" onclick="'','','scrollbars,width=500,height=500'); void('');"> but the problems with that are:

1) If I keep the target="blank", I have two windows that open up. If I remove target="blank", the form redirects itself to in the main window AND opens up in a new window. I just want it to open in a new window and leave the main window alone.
2) In the new onclicked window, I can't get my data to print anymore. I'm thinkink that since it's using JS to open the new window, all the form parameters are lost. Is that true? Anyone have ideas on how to fix this problem?

20040105 Edit by castaway: Changed title from 'To open a form in a new window'

Replies are listed 'Best First'.
Re: (OT) To open a form in a new window
by fruiture (Curate) on Jan 04, 2004 at 13:38 UTC

    This is not a Perl problem, but anyway: the method accepts a name of the new window as second parameter. This allows you to specify that window as a target for something, for example a form.

    <form target="form_results" ...> ... <input type="submit" value="Go" onclick="'','fo +rm_results','...');void(0)" /> </form>
      So you're saying if I used print header, start_html('MyNewPage'); as the title of the, I'd write <input type="submit" value="Go" onclick="'','MyNewPage','...');void(0)" /> ?

        No. You're confusing the title of an HTML-Document with the name of a frame/window. It's completely irrelevant what actually prints. Everything concerning windows happens on the clientside. The HTML i wrote already did all the necessary stuff: on submit-button-click a window is created (without content) an named "form_results" and the form has the target "form_results" which causes the browser to put the response of your into that window, if he is capable of and configured for handling multiple windows.

        This has still nothing to do with Perl.

Re: (OT) To open a form in a new window
by bart (Canon) on Jan 04, 2004 at 21:39 UTC
    Do two things:
    1. In the onsubmit event of the form, open a new window with a recognizable, hopefully unique name. You can set it up however you like.
    2. Add a target attribute for the form, with this window's name as the attribute value.
    Now, the result of the query will appear in this new custom window.

    In addition, you could set the focus on this window when you open it, with the win.focus() call. This will make this window come to the front, in case it already existed.

Re: (OT) (OT) To open a form in a new window
by sulfericacid (Deacon) on Jan 04, 2004 at 13:12 UTC
    I wouldn't know how to make it stop redirecting in the same window, but if the data is lost in the new window maybe you could try a url_param. Instead of, use something like
    my $forminfo = param('forminfo');$forminfo
    Then in, do something like:
    my $forminfo = param('stuff'); if ($forminfo) { print "Hello world!\n"; print "$forminfo"; }
    I have no idea if this will help your problem, but if you pass the paramaters as part of the URL itself, maybe it will help.

    "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://318654]
Approved by sulfericacid
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2018-04-21 22:15 GMT
Find Nodes?
    Voting Booth?