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

View info from Pop up window into parent that invoked pop up.

by peacemaker1820 (Pilgrim)
on Jul 10, 2002 at 14:25 UTC ( #180763=perlquestion: print w/replies, xml ) Need Help??

peacemaker1820 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks.
Thanks for your provious responce...but my page is not doing what it supposed to do.

Here it is again:
I have a page(parent) from where I am popping up a window in perl. There are some input boxes in that pop up window. Upon submission of my pop up window form, I would like my original page(parent), to reload and display the info that was in the pop up window.
Some of the responces that I got from you guys was:
opener.location="cgi_script?param" OR window.opener.location.reload();
These snippets of code worked but there is one problem.
My values in my parent form are set to default..I don't want that. I want the values to remain PLUS add the value from the pop up window. How do I do that?

Thanks Brothers for answering a non-perl question.
Appreciate it very much.

Replies are listed 'Best First'.
Re: View info from Pop up window into parent that invoked pop up.
by Joost (Canon) on Jul 10, 2002 at 14:41 UTC
    This is more of a javascript question, but you could try something like this untested code:

    in the popup

    <form action="#" onSubmit="submit_it(this);"> .... </form> <script language="javascript"> function submit_it(form) { for (var i=0; i < form.elements.length; i++) { opener.forms[0].elements['hidden_'+form.elements[i].name].value = f +orm.elements[i].value; } </script>
    and then add hidden fields to the form in your opener named 'hidden_[name_of_field_in_popup]'

    ofcourse if you use things like radios, checkboxes or select fields, you need to test for those too.

    Take a look at PPKs javascript section for much more information on coding javascript.

    An other technique could be to open the popup with the data from the opener in hidden fields... i cannot really say what the best solution would be without more info.

    -- Joost downtime n. The period during which a system is error-free and immune from user input.
Re: View info from Pop up window into parent that invoked pop up.
by George_Sherston (Vicar) on Jul 10, 2002 at 15:05 UTC
    Does the user enter values in the parent window as well as the pop-up window? And you want to combine all these values? If so then you'll need to submit the form in the parent window at the same time you launch the pop-up, then store that info somewhere your script can get it (perhaps a unique filename which you pass to the pop-up) and then pick it up again with the script that runs when you submit the form in the pop-up.

    Confused? I am.

    I'm not quite clear about what this means:

    I want the values to remain PLUS add the value from the pop up window

    ... do you mean numerical addition, or more data fields or what? In any event, as I say, you'll need to submit the parent data and save it, then send the pop-up window a filename in a hidden field, so you can find the data again when the pop-up submits.

    I promise not to repeat myself again (sic) if you post some code!

    George Sherston
      When I said
      I want the values to remain PLUS add the value from the pop up window
      What I meant was that I wanted to populate my texboxes in my parent form with the values that were entered in the pop up. However, before the pop up window was opened, some fields in my parent form were filled in already. Therefore, I want the values in the texboxes of my parent window to remain, PLUS populate the values from the pop up window into my parent form.
        In that case you have two options. You can either do some slightly complex javascript in the pop-up using window.opener to refer back to the parent window and set the values in the parent form, or you can, as I suggested, submit the parent form at the same time you launch the pop-up, cache the submitted values, and then, when you submit the form in the pop-up, combine the two values.

        Why not pick whichever of these suits your expertise, have a go, and then, in the unlikely even it doesn't work, post the code here, and someone will probably be able to fix it up

        George Sherston

        George Sherston
Re: View info from Pop up window into parent that invoked pop up.
by Moonie (Friar) on Jul 10, 2002 at 16:31 UTC
    Just for future reference - for javascript questions in general - a good forum to visit is: Coding Forums.
    - Moon

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://180763]
Approved by virtualsue
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2019-08-24 20:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?