Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Passing values to new window


Message #1 by "Pat Waddington" <paw@s...> on Thu, 16 Aug 2001 13:59:25 +0100
Try usin the showModalDialog method which get three
parameters: the name of the URL to be open, the
parameters you want to pass of the modal window, and
features like width, height, statusbar, scrolling etc.
The parameters are any object, variables and what you
want. Refering to the parameters is simple. In the
modal dialog you refer it like this:
window.dialogArguments...
Example:
showModalDialog("dlg.htm",window,"width:300px;height:400px");
In the modal window, you refer the parameter:
alert(window.dialogArguments.document.title);
window.dialogArguments is the opener window. Good
luck!


--- Pat Waddington <paw@s...> wrote:
> Thanks very much
> 
> ----- Original Message -----
> From: "Phil Griffiths" <pgtips@m...>
> To: "javascript" <javascript@p...>
> Sent: Thursday, August 16, 2001 3:14 PM
> Subject: [javascript] Re: Passing values to new
> window
> 
> 
> > You don't need a variable, in the opened window u
> can just use something
> > like
> > ...
> > temp=window.opener.test.GC.value;
> > alert (temp);
> > ...
> > to read the value of that field directly.
> >
> > > Hi all,
> > >
> > > I am annoyed with myself for having to ask this
> question, because I'm
> > > sure I've done it before. However, solving my
> problem is very urgent,
> > > and I've disposed of the 'mucking around' code
> that I used before.
> > >
> > > I have a page that updates a database. In this
> page, I wish to include a
> > > button that allows the user to build and print a
> document using the
> > > updated database. So (on button click), I open a
> new window - no problem
> > > there. However, I need to pass the new page a
> value so that it knows
> > > which record to get from the database to build
> the document.
> > >
> > > I think I have achieved this before by setting
> the variable in page
> > > 1(the update page),  then in the new page using
> > > window.opener.variablename to get the required
> value. I simply cannot
> > > get it to work any more. Test pages are:
> > >
> > >  The CALLING page:
> > > <html>
> > > <head>
> > > <title>Call Print</title>
> > > </head>
> > > <script language="javascript">
> > > function PrintCoverNote()
> > > {
> > > var GC=document.test.GC.value;
> > > alert (GC);
> > > // This displays OK
> > >
>
objPrintPage=window.open("CoverNotePrint.asp",width="400",height="400")
> > > }
> > > </script>
> > > <body>
> > > <script language="javascript">
> > > var GC=3Ddocument.test.GC.value;
> > > file://This alert does not happen
> > > alert (GC);
> > > </script>
> > > <form method="POST" action="temp.asp"
> name="test">
> > >  align="center"><center><p><input type="text"
> name="GC"
> > > size="20" value="GarageCode"></p>
> > >   </center></div><div
> align="center"><center><p><input type="button"
> > > value="Print"
> > >   name="PrintButton"
> onClick="PrintCoverNote()"></p>
> > >   </center></div>
> > > </form>
> > > </body>
> > > </html>
> > >
> > > The NEW PAGE:
> > > <html>
> > > <head>
> > > <title>New Page </title>
> > > </head>
> > > <body>
> > > <script language="javascript">
> > > temp=window.opener.GC
> > > alert ("temp");
> > > // This displays 'undefined'
> > > </script>
> > > </body>
> > > </html>
> > >
> > > I obviously have something wrong somewhere, but
> I'm xxxxed if I can see
> > > it.
> > >
> > > Any suggestions, help, comments (even of the
> 'what a moron' type)
> > > gratefully accepted.
> > >
> > > Thanks
> > > Pat
> 


  Return to Index